rules: anchor features offset to section header in rule formatter - #3143
rules: anchor features offset to section header in rule formatter#3143SkxOverKill wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Please add bug fixes, new features, breaking changes and anything else you think is worthwhile mentioning to the master (unreleased) section of CHANGELOG.md. If no CHANGELOG update is needed add the following to the PR description: [x] No CHANGELOG update needed
|
@SkxOverKill what is the relation between this PR and #3135? |
CHANGELOG updated or no update needed, thanks! 😄
|
Thanks for asking. #3143 is functionally a duplicate of the earlier #3135: both fix #3134 by anchoring the formatter offset to the actual top-level eatures: section, and both add regression coverage for a metadata description in a eatures namespace. #3135 predates this PR and is already approved, but it remains blocked on its contributor's CLA. I have updated this PR to acknowledge that relationship and @Makeph's earlier contribution explicitly. I also added the missing changelog entry and revalidated the formatter/rules/cache tests (45 passed), so #3143 is available strictly as a CLA-compliant fallback. If #3135 becomes mergeable, I am happy for this PR to be closed in its favor. |
Summary
Fixes #3134 by preventing
Rule.to_yaml()/capafmtfrom corrupting rules whose namespace contains the substringfeatures, such asimpact/features/persistence.Relationship to #3135
This PR is functionally a duplicate of the earlier #3135: both address #3134 by anchoring the formatter's search to the actual top-level
features:section and both add regression coverage for a metadata description combined with afeaturesnamespace.#3135 predates this PR and has already received maintainer approval. This PR is retained only as a CLA-compliant fallback because #3135 remains blocked on its contributor's CLA. If #3135 becomes mergeable, this PR should be closed in its favor. Credit to @Makeph for the earlier contribution and analysis in #3135.
Root Cause
The formatter located the start of the features block with:
Because
str.find()returns the first matching substring, a namespace containingfeaturescaused the offset to point into rule metadata. The subsequent feature-description indentation adjustment then also modified the metadata description, producing invalid YAML.Implementation
\n features:.namespace: impact/features/persistenceand metadata/feature descriptions.master (unreleased)inCHANGELOG.md.Verification