Skip to content

fix(codegen): normalize and validate CodeGenConfig::extern_paths in generate - #847

Open
dev-burnern wants to merge 1 commit into
anthropics:mainfrom
dev-burnern:fix/codegen-validate-extern-paths
Open

dev-burnern wants to merge 1 commit into
anthropics:mainfrom
dev-burnern:fix/codegen-validate-extern-paths

Conversation

@dev-burnern

Copy link
Copy Markdown

Closes #703

Summary

generate_with_diagnostics (and generate) now normalize and validate every proto name in CodeGenConfig::extern_paths via normalize_extern_path_proto_name, matching the existing exclude_packages check right above it.

  • Valid unnormalized entries (e.g. "my.common", ".my.common.", " my.common ") are normalized to canonical dotted form (".my.common") before building CodeGenContext, using Cow::Borrowed when every entry is already normalized so there is zero extra cloning for protoc-gen-buffa and buffa-build callers.
  • Malformed entries (e.g. ".my..common", "", "my.123") return CodeGenError::Other with normalize_extern_path_proto_name's error message quoting the entry as given.
  • Updates CodeGenConfig::extern_paths rustdoc to reflect that generate / generate_with_diagnostics now normalize and validate entries (while protoc-gen-buffa and buffa-build keep their upfront check before protoc runs).
  • Adds .changes/unreleased/fixed-20261122-175500.yaml changelog fragment.

Verification

  • cargo fmt --check — passed
  • cargo test -p buffa-codegen --lib — 852 passed, 0 failed (including new generate_normalizes_extern_paths_for_direct_callers and generate_rejects_malformed_extern_paths_for_direct_callers)
  • cargo clippy -p buffa-codegen --all-targets -- -D warnings — passed
  • RUSTDOCFLAGS="-D warnings" cargo doc -p buffa-codegen --no-deps — passed

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@dev-burnern

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 22, 2026

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.

codegen: generate does not check CodeGenConfig::extern_paths, so a direct caller's malformed proto name is kept and never matches a type

1 participant