Validate changelog section keys at parse-time using changelogs/sections.yaml#4516
Closed
Copilot wants to merge 3 commits into
Closed
Validate changelog section keys at parse-time using changelogs/sections.yaml#4516Copilot wants to merge 3 commits into
changelogs/sections.yaml#4516Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/envoyproxy/toolshed/sessions/49815067-7ab7-41b6-9254-953ef96bc50c Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Agent-Logs-Url: https://github.com/envoyproxy/toolshed/sessions/49815067-7ab7-41b6-9254-953ef96bc50c Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refine changelog typing support based on review feedback
Validate changelog section keys at parse-time using May 14, 2026
changelogs/sections.yaml
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 PR tightens changelog schema control without reintroducing hard-coded section names in typing. Section keys remain flexible at the type level, but are now validated at runtime against
changelogs/sections.yamlwherever parsed changelog data enters the system.Typing refinement (without hard-coded section keys)
SourceChangelogChangeSectionsDict = dict[str, SourceChangeList]for typed source-entry section maps.ChangelogSourceDictandChangelogDictasdict[str, Any].AChangelogs.validate_sections, whileBaseChangelogDictcontinues to carrydate: str.Runtime section validator on
AChangelogsvalidate_sections(self, data, path=None) -> ChangelogDict.dateunconditionally.self.sections(loaded fromchangelogs/sections.yaml).ChangelogParseErrorwith unknown section names, optional source path context, and a pointer toCHANGELOG_SECTIONS_PATH.dataunchanged on success so call sites can inline it.Parse-path wiring
AChangelog.datato validate parsed data via:self.project.changelogs.validate_sections(await self.project.execute(self.get_data, self.path), self.path)AChangelog.get_dataunchanged (still classmethod-based parsing).Test coverage
validate_sections:datehandling,AChangelog.datatest to assert validator invocation and return value.ChangelogParseErroronawait changelog.data.Original prompt
Context
This refines PR #4500 (branch
copilot/relax-changelogtyping-support), part of the per-entry changelog plan (see #4498, #4499, and sibling PRs #4501 / #4502).The reviewer's feedback on the current state of PR #4500:
What this PR should do
Two changes, in this order:
1. Tighten the typing (partial revert of the current PR #4500 state)
Current state on the branch (
py/envoy.base.utils/envoy/base/utils/typing.py):Change to:
i.e. keep
ChangelogSourceDict/ChangelogDictasdict[str, Any](the looseness is necessary so arbitrary section keys don't trigger mypy errors), but:SourceChangelogChangeSectionsDictalias (mirrorsChangelogChangeSectionsDictbut usesSourceChangeList) so PR 2's directory reader has a typed intermediate shape to build from.AChangelogs.validate_sectionsas the runtime authority.BaseChangelogDictunchanged (it carries thedate: strcontract that consumers still rely on, even thoughChangelogDictno longer inherits from it after this PR).Do not re-introduce hard-coded section keys.
2. Add a runtime section validator on
AChangelogsFile:
py/envoy.base.utils/envoy/base/utils/abstract/project/changelog.pyAChangelogsalready loadschangelogs/sections.yamlintoself.sections(aChangelogSectionsDict, i.e.dict[str, ChangelogSectionDict]). That's the schema. Add a method that uses it:Notes:
exceptions.ChangelogParseErrorfor consistency withAChangelog.get_data's existing error path."date"key is always allowed (it's the one typed field).pathis optional so callers that don't have a meaningful path (e.g. an in-memory dict) can still call it.data; return it as-is on success.3. Wire
validate_sectionsinto the existing parse pathAChangelog.get_data(classmethod, lines ~132-149) currently does:It is a
classmethod, so it does not have access to anAChangelogsinstance. The wiring should therefore happen at the call site that does have access —AChangelog.data:This:
get_datapure / classmethod-friendly (PR 2's `get_...This pull request was created from Copilot chat.