Merged
Conversation
Benchmark ResultBenchmark diff with base branchBenchmark result |
abhisheksplunk
approved these changes
Jan 27, 2026
Collaborator
Author
|
@abhisheksplunk this is stacked on top of #340 |
0603547 to
4a0ed09
Compare
842c4f1 to
74ddef6
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a security and correctness issue by disallowing empty root structs in the STEF schema. Empty root structs cause decoders to enter a no-progress state where they can decode an unbounded number of empty records without consuming input data, making it difficult to protect against malformed inputs.
Changes:
- Added compile-time validation in the schema parser to reject empty root structs with a clear error message
- Added runtime validation in generated decoders to return an error when attempting to decode data with zero fields in the root struct
- Updated schema shrinking utilities to preserve at least one field in root structs during testing
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| go/pkg/idl/parser.go | Adds parser validation to reject empty root struct definitions |
| go/pkg/idl/parser_test.go | Adds test case for empty root struct validation and updates existing tests to use non-empty root structs |
| stefc/templates/go/struct.go.tmpl | Adds runtime check in generated decoder Init method to reject empty root structs |
| go/pkg/errors.go | Defines new error constant ErrEmptyRootStructDisallowed |
| go/otel/otelstef/spans.go | Generated code with runtime validation for Spans decoder |
| go/otel/otelstef/metrics.go | Generated code with runtime validation for Metrics decoder |
| examples/profile/internal/profile/sample.go | Generated code with runtime validation for Sample decoder |
| examples/jsonl/internal/jsonstef/record.go | Generated code with runtime validation for Record decoder |
| examples/ints/internal/ints/record.go | Generated code with runtime validation for Record decoder |
| go/pkg/schema/utils.go | Updates schema shrinking logic to prevent removing the last field from root structs |
| go/otel/otelstef/testdata/fuzz/FuzzSpansReader/3377d71d4f33a55f | Adds fuzz test corpus that triggers the empty root struct error |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Resolves #341 Emptry root struct cannot work since decoding it is a noop and never reaches the end of column, thus potentially allowing a very large number of such empty records to be "decoded" by Reader without making any progress. This makes protecting from invalid inputs hard. We now disallow this, since there is no plausible use case for a schema like this. We still allow empty non-root structs, which is a valid way to have a schema that can evolve by adding fields to empty struct. It does not suffer from the same problem since Reader will have to make some progress for non-empty root struct and will eventually reach end of column for root struct. We also disallow this in stefc schema parser.
74ddef6 to
556f6e3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #341
Emptry root struct cannot work since decoding it is a noop and never reaches the end of column, thus potentially allowing a very large number of such empty records to be "decoded" by Reader without making any progress. This makes protecting from invalid inputs hard.
We now disallow this, since there is no plausible use case for a schema like this.
We still allow empty non-root structs, which is a valid way to have a schema that can evolve by adding fields to empty struct. It does not suffer from the same problem since Reader will have to make some progress for non-empty root struct and will eventually reach end of column for root struct.
We also disallow this in stefc schema parser.