Preserve per-entry changelog errors on parse failure and switch envoy.code.check to shared entry constants#4520
Closed
Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/envoyproxy/toolshed/sessions/62ea0bc0-84d1-4bb0-8276-365f758b15fe Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Agent-Logs-Url: https://github.com/envoyproxy/toolshed/sessions/62ea0bc0-84d1-4bb0-8276-365f758b15fe Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refine per-entry filename validation for envoy.code.check
Preserve per-entry changelog errors on parse failure and switch May 14, 2026
envoy.code.check to shared entry constants
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This follow-up tightens the per-entry changelog validation added in the earlier PR. The main issue was error masking: once section validation started raising during
await self.data,AChangelogStatus.errorscould return a single coarse parse error and drop the per-file filename/content errors that this checker is meant to surface.Error aggregation
check_entry_files()before the parse-dependent checks inAChangelogStatus.errors.ChangelogParseError, return per-entry file errors first, then the coarse parse error.Shared changelog entry constants
ENTRY_SEPARATOR/CHANGELOG_ENTRY_GLOBdefinitions inenvoy.code.check.abstract.changelog.envoy.base.utils.abstract.project.changelog, matching the landed dependency shape.Test rewrites
check_entry_filenameunit tests to use fully mocked path objects (MagicMock) instead ofpathlib.Pathliterals.parent.name,stem, andsuffix.Ordering/call expectation updates
test_changelogstatus_errorsto reflect the new failure ordering:check_entry_files()is invoked unconditionally, including when parsing later fails.Branch-local dependency alignment
py/envoy.code.checksource/test targets at the localenvoy.base.utilssource target so the shared constants resolve from the in-repo implementation expected by this stacked change.Original prompt
Context
This refines PR #4502 (branch
copilot/featureper-entry-filename-validation), which adds per-entry filename and content validation toenvoy.code.check.The dependencies it was waiting on have now landed:
envoy.base.utils: Add per-entry RST directory reader #4518 — per-entry RST directory reader inenvoy.base.utils, exposing module-level constantsENTRY_SEPARATORandCHANGELOG_ENTRY_GLOBinenvoy.base.utils.abstract.project.changelog.envoy.base.utils: Switch to runtime validation for changelog sections #4519 — runtimevalidate_sectionsonAChangelogs, called fromAChangelog.data. Any unknown section key in a parsed changelog now raisesutils.exceptions.ChangelogParseErrorfromawait self.data, whichcheck_dateandcheck_sectionsboth go through.Three concrete changes needed.
1. Fix
errors()ordering so per-file errors survive a parse failureFile:
py/envoy.code.check/envoy/code/check/abstract/changelog.pyCurrent state on the branch:
After #4519,
await self.data(called viacheck_dateandcheck_sections) runsvalidate_sections, which raisesChangelogParseErroron any unknown section key. With current ordering, this is caught anderrorsreturns a single coarse message — the per-file errors fromcheck_entry_filesare never collected, defeating the purpose of this PR.check_entry_filesis parse-independent: it only globs the filesystem and usesself.checker.sections(loaded directly fromsections.yaml, not viaself.data). Hoist it before the try block:Guarantees:
2. Replace TODO local constants with imports from
envoy.base.utilsCurrently:
PR #4518 landed; these constants exist in
envoy.base.utils.abstract.project.changelog. Replace local definitions with an import — match the existing import style in this file (which already importsutils.typing/utils.exceptions). Direct import fromenvoy.base.utils.abstract.project.changelogis acceptable; do not aggressively re-architect re-exports.Remove the TODO comment. Update any call sites still using the bare names (they should resolve via the import).
3. Rewrite
check_entry_filenametests with fully-mocked pathsFile:
py/envoy.code.check/tests/test_abstract_changelog.pyThe seven
check_entry_filenametests added by #4502 use realpathlib.Pathliterals:The convention in adjacent test files (canonical example:
test_abstract_changelog_get_data_from_entries_*inpy/envoy.base.utils/tests/test_abstract_project_changelogs.py) is fully-mocked "ALL and ONLY" style.Rewrite all seven tests:
test_changeschecker_check_entry_filename_validtest_changeschecker_check_entry_filename_invalid_sectiontest_changeschecker_check_entry_filename_wrong_extensiontest_changeschecker_check_entry_filename_no_separatortest_changeschecker_check_entry_filename_multiple_separatorstest_changeschecker_check_entry_filename_empty_areatest_changeschecker_check_entry_filename_empty_slugIn each:
path = MagicMock()— do not constructpathlib.Path.path.parent.name,path.stem(real strings so.split/.countwork),path.suffix.is Nonefor valid; substring checks for the others).path.parent.nametext ("weird_section"etc.) — they still work because the production code interpolatespath.parent.namewhich we set explicitly."Area"/"empty") or setpath.__str__so the resulting string is known. Prefer dropping unless the message would be meaningless without the path.Pa...
This pull request was created from Copilot chat.