fix: return real defaults when codeowners.toml fails to parse - #184
Open
asyncawaitpromise wants to merge 1 commit into
Open
fix: return real defaults when codeowners.toml fails to parse#184asyncawaitpromise wants to merge 1 commit into
asyncawaitpromise wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the 'Approval Retention' feature, which allows users to configure whether existing approvals are retained across specific types of changes, such as whitespace, comments, formatting, string literals, or renames. The implementation includes updates to the configuration parser, new helper methods for flag resolution, comprehensive unit and integration tests, and updated documentation in the README. Since there are no review comments, I have no additional feedback to provide.
asyncawaitpromise
force-pushed
the
fix/config-partial-parse
branch
from
August 19, 2026 00:50
0572660 to
2c52723
Compare
asyncawaitpromise
changed the base branch from
main
to
feat/approval-retention-config
August 19, 2026 08:11
asyncawaitpromise
marked this pull request as ready for review
August 20, 2026 09:19
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| internal/config/config.go | Separates the TOML decode target from freshly constructed error-path defaults, preventing partially parsed policy values from escaping. |
| internal/config/config_test.go | Adds a malformed-config regression test that exercises and compares all current Config fields against pristine defaults. |
| README.md | Updates the displayed test coverage percentage. |
| internal/git/diff_test.go | Applies a formatting-only alignment adjustment to an existing expected map. |
Reviews (2): Last reviewed commit: "fix: return real defaults when codeowner..." | Re-trigger Greptile
asyncawaitpromise
marked this pull request as draft
August 21, 2026 21:33
asyncawaitpromise
force-pushed
the
feat/approval-retention-config
branch
from
August 24, 2026 20:59
b313dc9 to
86cc504
Compare
asyncawaitpromise
force-pushed
the
fix/config-partial-parse
branch
from
August 24, 2026 20:59
2c52723 to
3be27af
Compare
asyncawaitpromise
force-pushed
the
fix/config-partial-parse
branch
from
September 1, 2026 05:11
3be27af to
82813dc
Compare
asyncawaitpromise
changed the base branch from
feat/approval-retention-config
to
main
September 1, 2026 05:11
asyncawaitpromise
force-pushed
the
fix/config-partial-parse
branch
from
September 1, 2026 06:49
a559a88 to
0f98ba8
Compare
ReadConfig handed the same default Config to the TOML parser and to its own error paths. go-toml dereferences a non-nil pointer in place rather than allocating, so a file which failed halfway left its partially parsed values in the instance the error path then returned. The caller logs "using default config" and carries on, with whatever the parser managed to read before it failed. A malformed file could therefore turn enforcement off, or widen admin bypass, while the logs said defaults were in force. Build a fresh instance per call instead: the parser gets its own, and every error path builds another. The nil-section fixups go with it, since defaults can no longer be clobbered and TOML cannot express a null table. The regression test asserts the whole struct against pristine defaults rather than sampling a couple of sections. On the unfixed code fourteen fields survive the failed parse, including enforcement.approval and admin_bypass.enabled. Coverage badge regenerated.
asyncawaitpromise
force-pushed
the
fix/config-partial-parse
branch
from
September 1, 2026 07:25
0f98ba8 to
81bf7a6
Compare
asyncawaitpromise
marked this pull request as ready for review
September 1, 2026 07:28
|
Codeowners approval required for this PR: |
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.
Summary / Background
ReadConfighanded the same defaultConfigto the TOML parser and to its ownerror paths. go-toml dereferences a non-nil pointer in place rather than
allocating a replacement (
unmarshaler.go, the pointer walk inwalkTable), so a file which failed halfway left its partially parsedvalues in the instance the error path then returned.
The caller logs
using default configand carries on, with whatever the parsermanaged to read before it failed.
Why it matters
A malformed
codeowners.tomlcould turn enforcement off, or widen admin bypass,while the logs said defaults were in force. The config is a security boundary, so
an error path has to return values that never reflect anything read from the file.
The fix
A fresh instance per call. The parser gets its own, and every error path builds
another.
The nil-section fixups go with it. They only ever ran on the success path, and on
that path they were unreachable: TOML cannot express a null table, so a section
which starts non-nil cannot come back nil.
Note that a shallow struct copy is not enough here. The pointer fields would
still be shared, which is exactly what go-toml merges into.
Verification
A test parses a file whose
[enforcement]and[admin_bypass]sections are bothread successfully before a later line fails to parse, then asserts every returned
field equals the real default. Reverting the fix turns it red.