Skip to content

Conversation

patrickhuie19
Copy link
Contributor

@patrickhuie19 patrickhuie19 commented Aug 11, 2025

This pull request introduces support for excluding specific proto files from registration and refactors the proto registration workflow to use proper topological sorting based on file dependencies. It also improves logging and simplifies code paths for proto file fetching and caching.

Proto file exclusion support:

  • Added an ExcludeFiles field to the ProtoSchemaSet struct, allowing users to specify proto files to exclude from registration. The exclusion logic is now applied when fetching proto files from both GitHub and the local filesystem. (framework/components/dockercompose/chip_ingress_set/protos.go, [1] [2] [3]

Dependency-aware registration:

Improved proto file fetching and caching:

  • Updated proto file fetching functions to accept and respect the ExcludeFiles parameter, ensuring excluded files are not processed or cached. (framework/components/dockercompose/chip_ingress_set/protos.go, [1] [2] [3] [4]
  • Fixed cache writing and reading logic to use the correct file paths and error messages. (framework/components/dockercompose/chip_ingress_set/protos.go, framework/components/dockercompose/chip_ingress_set/protos.goL319-L327)

Logging and minor improvements:

  • Improved logging for proto file fetching, exclusion, and registration steps, including info-level logs and clearer debug messages. (framework/components/dockercompose/chip_ingress_set/protos.go, [1] [2]
  • Minor cleanups in configuration validation and error handling. (framework/components/dockercompose/chip_ingress_set/protos.go, [1] [2]

@patrickhuie19 patrickhuie19 requested a review from a team as a code owner August 11, 2025 23:20
Copy link

👋 patrickhuie19, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@patrickhuie19 patrickhuie19 requested a review from Tofel August 12, 2025 16:22
// So if the import is "workflows/v1/metadata.proto", the name should be "v1/metadata.proto"
// And if the import is "workflows/v2/cre_info.proto", the name should be "v2/cre_info.proto"
importName := dep
if strings.HasPrefix(dep, "workflows/") {
Copy link
Contributor

Choose a reason for hiding this comment

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

this will only work with current folder structure. That's why I was removing that prefix dynamically. I'd rather not hardcode that workflows/ removal and keep it dynamic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mm. i'm the owner of those protos and I don't see a reason to change the folder structure.


// Check if schema is already registered
if existingID, exists := checkSchemaExists(schemaRegistryURL, subject); exists {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should do that before if depSubject, depExists := subjectMap[dep]; depExists {?


// Check if schema is already registered
if existingID, exists := checkSchemaExists(schemaRegistryURL, subject); exists {
framework.L.Info().Msgf("Schema %s already exists with ID %d, skipping registration", subject, existingID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug?

// The schema registry expects import statements without the 'workflows/' prefix
// So we need to modify the protobuf content to replace "workflows/v1/..." with "v1/..." and "workflows/v2/..." with "v2/..."
modifiedSchema := strings.ReplaceAll(schema.Source, `"workflows/v1/`, `"v1/`)
modifiedSchema = strings.ReplaceAll(modifiedSchema, `"workflows/v2/`, `"v2/`)
Copy link
Contributor

Choose a reason for hiding this comment

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

same as before ;-)

if _, exists := protoMap[importPath]; exists {
// Check for self-reference
if importPath == path {
framework.L.Warn().Msgf("Self-reference detected: %s imports itself!", path)
Copy link
Contributor

Choose a reason for hiding this comment

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

would that mean that proto is invalid or our code is buggy? if it is the former, maybe we should err?

Copy link
Contributor Author

@patrickhuie19 patrickhuie19 Aug 27, 2025

Choose a reason for hiding this comment

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

potentially either - but now that we parse the directories dynamically and strip the suffixes, it could also be because there are overlapping paths at one level down: i.e.,

/workflows/event_started.proto
/capabilities/event_started.proto

continuing here allows us to register the rest of the protos; that seems like the best middle ground for how stable the framework is atm.

@patrickhuie19 patrickhuie19 enabled auto-merge (squash) August 27, 2025 14:07
@patrickhuie19 patrickhuie19 merged commit 2284539 into main Aug 27, 2025
68 checks passed
@patrickhuie19 patrickhuie19 deleted the chore/exclude-files branch August 27, 2025 14:42
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