Skip to content

Fix --exclude-imports with --path or --type - #4775

Open
oliversun9 wants to merge 17 commits into
mainfrom
osun/type-and-import
Open

oliversun9 wants to merge 17 commits into
mainfrom
osun/type-and-import

Conversation

@oliversun9

@oliversun9 oliversun9 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

The correct order of filtering:

  1. apply the path filters
  2. apply the type filters
  3. trim imports

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedNov 10, 2026, 5:21 PM

@oliversun9
oliversun9 marked this pull request as ready for review November 6, 2026 23:30
@oliversun9
oliversun9 force-pushed the osun/type-and-import branch from 54d0b64 to 0057121 Compare November 9, 2026 08:55
@oliversun9
oliversun9 marked this pull request as draft November 9, 2026 08:56
@oliversun9
oliversun9 marked this pull request as ready for review November 9, 2026 10:05
@oliversun9
oliversun9 marked this pull request as draft November 10, 2026 09:21
@oliversun9
oliversun9 marked this pull request as ready for review November 10, 2026 11:07

@emcfarlane emcfarlane left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm, small comments on wording.

Comment thread proto/buf/alpha/image/v1/image.proto Outdated
Comment on lines +77 to +78
// 3. A file that is not itself a target, but is (possibly transitively)
// imported by a target file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe could clarify this wording a bit. The not itself a target reads to me as a file is not an import if its not imported which is circular. Maybe?

3. A file that a target file depends on.

Comment thread proto/buf/alpha/image/v1/image.proto Outdated
Comment on lines +80 to +82
// When a type filter is allowed to select types from imported files, as the
// BSR does, a file that defines a selected type is a target even if it falls
// under one of the cases above.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This too. I think the wording needs to be closer to the FileDescriptor. Something along the lines of a "target file is always set to is_import false, regardless of which Module it derived from".

Comment on lines +133 to +136
// Normally, if `--path a.proto` is passed it's an error to pass `--type B`, because
// they don't intersect. However, if `--path a.proto` and `--type pkg` is passed and
// both a.proto and b.proto are in the pkg package, then it's valid. This time `--type pkg`
// does not make b.proto a target because it's excluded by `--path a.proto` already.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe describing as the union of paths intersected with the union of types would help?

Comment thread CHANGELOG.md Outdated

- Fix LSP hover and highlighting of CEL expressions whose proto strings contain escape sequences,
which placed the ranges of string literals, and of tokens after a `\u` or `\U` escape, wrongly.
- Fix a bug where a file imported by the file of a type specified by `--type`, without defining a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: could maybe wordsmith this a bit. The a bug is redundant. I think we want to just comment something like:

- Fix `buf build --type=X` filters to correctly mark non-targeted files as imports.

But should expand to cover path interactions and image changes.

This branch has not been deployed

No deployments
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.

2 participants