Skip to content

Include spanless diagnostics as file annotations in new compiler path#4517

Open
stefanvanburen wants to merge 2 commits intomainfrom
svanburen/file-annotations
Open

Include spanless diagnostics as file annotations in new compiler path#4517
stefanvanburen wants to merge 2 commits intomainfrom
svanburen/file-annotations

Conversation

@stefanvanburen
Copy link
Copy Markdown
Member

Matches the old compiler behavior where errors without source positions were still surfaced as FileAnnotations (with nil fileInfo), rather than being dropped or returned as raw errors. Updates TestWorkspaceDuplicateFailSpecificModule to expect exit code 100 (FileAnnotationSet) and the file-prefixed error format instead of the previous exit code 1 with a "Failure: " prefix.

Supersedes the approach in #4499.

Matches the old compiler behavior where errors without source positions
were still surfaced as FileAnnotations (with nil fileInfo), rather than
being dropped or returned as raw errors. Updates TestWorkspaceDuplicateFailSpecificModule
to expect exit code 100 (FileAnnotationSet) and the file-prefixed error format instead of
the previous exit code 1 with a "Failure: " prefix.

Supersedes the approach in #4499.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedApr 28, 2026, 11:30 PM

Comment thread cmd/buf/workspace_test.go Outdated
t,
nil,
1,
100,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Urgh, sorry for being annoying about this, and this gives me a little bit of extra insight on how the compiler diagnostics have always been... so unfortunately, this would be considered a breaking change (exit code + stdout/stdwarn behaviour)...

So I think the approach we need to take here is:

  • We continue to suppress the diagnostics with no primary span
  • And then have DuplicateProtoPathError continue to be surfaced through the module build

We should document this in the code path where we do this pretty carefully, since this can be confusing to the reader of the code, but also, not introducing breaking behaviours is the priority.

Ideally, we would do an audit of the diagnostic surface area now that we have the new compiler in, but that may not be feasible right now -- in the short term, we need to prioritise retaining consistency in the high-level behaviour...

When a proto file is contained in multiple modules (DuplicateProtoPathError),
the new experimental compiler was silently swallowing the typed error: FDS
did not check the fatal error from its Link sub-query, producing an empty
FileDescriptorSet instead of propagating the error upward. This meant callers
of compileImage could not inspect it via errors.As, and the downstream
"nil FileDescriptor" panic was unhelpful.

The fix is in protocompile (bufbuild/protocompile#722): FDS.Execute now
checks linkResult[0].Fatal before iterating over IR files, propagating the
Link fatal as its own. With this, results[0].Fatal in compileImage is
DuplicateProtoPathError, which is returned directly so callers retain its
type information and the existing "Failure: " / exit code 1 behavior is
preserved.
@stefanvanburen
Copy link
Copy Markdown
Member Author

@doriable I'll update the PR description if you agree, but PTAL at 0808f44, which pulls in bufbuild/protocompile#722 instead and handles the fatal errors first, which I think should be what we want to do...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants