Skip to content

fix(validation): match feature files to the longest API name in scope#366

Merged
hdamker merged 1 commit into
camaraproject:mainfrom
hdamker:fix/feature-file-api-matcher-prefix-collision
Jul 7, 2026
Merged

fix(validation): match feature files to the longest API name in scope#366
hdamker merged 1 commit into
camaraproject:mainfrom
hdamker:fix/feature-file-api-matcher-prefix-collision

Conversation

@hdamker

@hdamker hdamker commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

bug

What this PR does / why we need it:

_stem_matches_api matched a feature-file stem {api-name}-{suffix} to {api-name}, so when one API name is a prefix of a sibling's (e.g. dedicated-network vs dedicated-network-areas), the shorter API claimed the sibling's .feature file and validated it against the wrong info.version. On DedicatedNetworks r2.2 (camaraproject/DedicatedNetworks#128) this surfaced as 11 false P-025 errors + 1 false P-007 hint on dedicated-network-areas.feature.

Root cause ran deeper than the matcher: the per-API dispatch in python_adapter.py narrows context.apis to a single element, so the three feature-file checks never saw sibling API names to disambiguate with.

Fix:

  • Add ValidationContext.all_api_names — the full release-scope API-name set. It survives the per-API dataclasses.replace narrowing, so API-scoped checks can see their siblings.
  • The matcher now lets the longest matching API name win: a {api-name}-{suffix} stem yields to a longer API name in scope that is also anchored on it. Per-operation split files (whose suffix is not itself an API name) still match their base API.
  • All three callers consult it: check-test-file-version (P-007), check-feature-file-url-version (P-025), and check-test-files-exist.

Which issue(s) this PR fixes:

Fixes #365

Special notes for reviewers:

Regression tests use the real DedicatedNetworks constellation (dedicated-network + dedicated-network-areas at different versions), covering all three callers plus the per-operation-split case (no over-correction). Regression and existing test_python_checks_* / test_context_builder unit tests pass locally.

Changelog input

 release-note
Fix feature-file→API matching so a prefix-sibling API no longer claims a longer sibling's test file (eliminates false P-025/P-007 on repos with prefix-related API names).

Additional documentation

This section can be blank.

docs

_stem_matches_api accepted a bare {api-name}-{suffix} stem, so a prefix-sibling
API (dedicated-network) over-claimed a longer sibling's feature file
(dedicated-network-areas.feature) and version-checked it against the wrong
info.version — a false P-025/P-007 FAIL on the DedicatedNetworks r2.2 release
review. The three feature-file checks now consult the full release-scope
API-name set (ValidationContext.all_api_names) so the longest matching name wins.

Fixes camaraproject#365
@hdamker hdamker requested review from Kevsy and rartych as code owners July 7, 2026 13:58
@hdamker hdamker merged commit 875ecac into camaraproject:main Jul 7, 2026
8 checks passed
@hdamker hdamker deleted the fix/feature-file-api-matcher-prefix-collision branch July 7, 2026 14:01
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.

Validation: feature-file→API matcher over-claims sibling APIs when one API name is a prefix of another

1 participant