Skip to content

fix: allow snake_case metadata keys in error catalogs - #149

Merged
zepatrik merged 1 commit into
masterfrom
fix/metadata-key-validation
Nov 13, 2026
Merged

zepatrik merged 1 commit into
masterfrom
fix/metadata-key-validation

Conversation

@zepatrik

@zepatrik zepatrik commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Allow error catalogs to declare snake_case metadata keys such as namespace_id and limit_per_request. Keys may contain underscores and hyphens after an initial lowercase ASCII letter; existing camelCase keys remain valid. Invalid characters and duplicate keys are still rejected.

Validation: full race test suite, Go vet, reproducible generation, and Buf compatibility against master. Regression tests cover accepted keys, preservation in generated JSON, and invalid keys.

Co-authored-by: Codex noreply@openai.com

Summary by CodeRabbit

  • Updates
    • Metadata keys now accept lowercase-leading names containing letters, digits, underscores, or hyphens. Keys with dots, spaces, slashes, non-ASCII characters, or invalid starting characters remain unsupported.
    • Error messages now show the required key format.

Accept underscores and hyphens in metadata keys while preserving existing camelCase keys and rejecting invalid characters.

Co-authored-by: Codex <noreply@openai.com>
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Metadata keys now allow underscores and hyphens after a lowercase ASCII letter. The error message and documentation state the updated pattern, and tests cover valid and invalid keys.

Changes: Metadata Key Validation

Layer / File(s) Summary
Metadata key rules and validation
herodotpb/proto/ory/herodot/v1/herodot.proto, v2/options.go, v2/cmd/protoc-gen-herodot/catalog.go, v2/cmd/protoc-gen-herodot/main_test.go
The validator accepts keys matching [a-z][a-zA-Z0-9_-]* and reports that pattern for invalid keys. Documentation reflects the updated key format. Tests check accepted and rejected keys.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 18e7d

Metadata keys in error catalogs may now include underscores and hyphens, and existing camelCase keys stay valid. No actionable merge risk remains.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description states the purpose: allow snake_case metadata keys such as namespace_id and limit_per_request, with underscores and hyphens allowed after an initial lowercase letter. It notes that cam… Add the template's 'Related Issue or Design Document' section. For a bug fix, link the issue in the format '#1234', or explain the bug and how to reproduce it. Add the 'Checklist' section and mark the items that apply, including the tests, …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: error catalogs now accept snake_case metadata keys. The raw summary confirms the validator in catalog.go, the options.go docs, and the tests were changed to allow unde…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: error catalogs now accept snake_case metadata keys. The raw summary confirms the validator in catalog.go, the options.go docs, and the tests were changed to allow underscores and hyphens. The title is short, specific, and matches the objectives. It uses the conventional 'fix:' prefix, which is acceptable.

Full details: Description check

Explanation

The description states the purpose: allow snake_case metadata keys such as namespace_id and limit_per_request, with underscores and hyphens allowed after an initial lowercase letter. It notes that camelCase keys remain valid and that invalid characters and duplicate keys are still rejected. It lists validation steps and regression test coverage. It does not follow the repository template. It has no Related Issue or Design Document section, no checklist, and no BREAKING CHANGES block. It does not state whether the change is a fix for a known bug and does not link an issue, which the template requires for fixes. The template's checklist items are not marked. The description is mostly complete on intent and testing, but the template sections are missing.

Resolution

Add the template's 'Related Issue or Design Document' section. For a bug fix, link the issue in the format '#1234', or explain the bug and how to reproduce it. Add the 'Checklist' section and mark the items that apply, including the tests, documentation, and CLA items. Add a 'Further comments' section if the change needs a design rationale. State that this change is not breaking, or add a BREAKING CHANGES block if it is.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Buf (1.74.0)

herodotpb/proto/ory/herodot/v1/herodot.proto

fatal: unable to access 'https://github.com/ory/herodot.git/': Failed to connect to github.com:443 over proxy 127.0.0.1 after 0 ms: Could not connect to server
fatal: could not fetch f7a4556e1e0daea13089ba2cf2330f7aaf5bc9ad from promisor remote

CODERABBIT_BUF_COMPATIBILITY_PHASE=materialize-base

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0cda9067-9163-43ef-a0df-3dab72d90de3
Commits

Reviewing files that changed from the base of the PR and between 4519854 and 18e7dbc.

Files ignored due to path filters: 1

  • herodotpb/herodot.pb.go is excluded by !**/*.pb.go
Files selected for processing: 4

  • herodotpb/proto/ory/herodot/v1/herodot.proto
  • v2/cmd/protoc-gen-herodot/catalog.go
  • v2/cmd/protoc-gen-herodot/main_test.go
  • v2/options.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@zepatrik
zepatrik merged commit 180bb3d into master Nov 13, 2026
11 checks passed
@zepatrik
zepatrik deleted the fix/metadata-key-validation branch November 13, 2026 10:19
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.

1 participant