fix(CODEWIKI-002): CU-86akn96pk 2 review findings in config.py - #96
flamingo[bot] wants to merge 1 commit into
Conversation
| dataclasses.asdict()) so that adding a new field to Config requires a | ||
| deliberate decision about whether/how it is serialized here. | ||
| """ | ||
| data = asdict(self) |
There was a problem hiding this comment.
🦩 🔴 Config.to_dict() delegates to asdict() instead of explicitly listing fields
Rewrote Config.to_dict() (codewiki/src/config.py) to build the returned dict by explicitly listing every non-secret field by name (repo_path, output_dir, ... additional_source_paths), instead of calling asdict(self) and popping secret keys afterward. Secret fields (cluster_api_key, main_api_key, fallback_api_key) are now only added to the dict explicitly when include_secrets=True, rather than being present by default and removed. This satisfies CODEWIKI-002's requirement that to_dict() explicitly enumerate fields, and it removes the "new field silently serialized" risk since any new dataclass field must be added to this list by hand to be included.
🤖 Prompt for AI agents
In codewiki/src/config.py around line 132, review and complete this code-review fix: Config.to_dict() delegates to asdict() instead of explicitly listing fields.
What the draft fix changed: Rewrote `Config.to_dict()` (codewiki/src/config.py) to build the returned dict by explicitly listing every non-secret field by name (repo_path, output_dir, ... additional_source_paths), instead of calling `asdict(self)` and popping secret keys afterward. Secret fields (cluster_api_key, main_api_key, fallback_api_key) are now only added to the dict explicitly when `include_secrets=True`, rather than being present by default and removed. This satisfies CODEWIKI-002's requirement that to_dict() explicitly enumerate fields, and it removes the "new field silently serialized" risk since any new dataclass field must be added to this list by hand to be included.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 88 medium — react 👍/👎 to teach the reviewer
| discarded, so that config drift between the CLI and backend Config is | ||
| surfaced instead of hidden. | ||
| """ | ||
| known_fields = {f.name for f in fields(cls)} |
There was a problem hiding this comment.
🦩 🟠 Config.from_dict silently drops unknown/extra fields including ones from a previous schema version
Changed Config.from_dict() (codewiki/src/config.py) to compute unknown = set(data.keys()) - known_fields and raise ValueError listing the unknown keys instead of silently filtering them out with a dict comprehension. This directly addresses the "silently drops unknown/extra fields" finding by turning schema drift into a visible error. Risk/incompleteness: this is a behavior change — any existing caller that relied on from_dict() tolerating extra/renamed keys (e.g. passing through a superset dict from a newer version) will now raise instead of degrading gracefully; a complete fix might instead want a warning-log path or an explicit migration/versioning mechanism, which is beyond a minimal in-file change and was not implemented here.
🤖 Prompt for AI agents
In codewiki/src/config.py around line 147, review and complete this code-review fix: Config.from_dict silently drops unknown/extra fields including ones from a previous schema version.
What the draft fix changed: Changed `Config.from_dict()` (codewiki/src/config.py) to compute `unknown = set(data.keys()) - known_fields` and raise `ValueError` listing the unknown keys instead of silently filtering them out with a dict comprehension. This directly addresses the "silently drops unknown/extra fields" finding by turning schema drift into a visible error. Risk/incompleteness: this is a behavior change — any existing caller that relied on from_dict() tolerating extra/renamed keys (e.g. passing through a superset dict from a newer version) will now raise instead of degrading gracefully; a complete fix might instead want a warning-log path or an explicit migration/versioning mechanism, which is beyond a minimal in-file change and was not implemented here.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.
fix confidence: 🔴 55 low — review closely — react 👍/👎 to teach the reviewer
Closes 2 review findings in
codewiki/src/config.py.Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
codewiki/src/config.py:132codewiki/src/config.py:147What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.
Run: https://product-hub.flamingo.so/admin/code-review
Run id:
9aa9712c-4ca2-4571-94bc-95e5cff4b3cdMerging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.
ClickUp task: CU-86akn96pk CodeWiki review findings sweep (9 PRs)