fix(CODEWIKI-007): CU-86akbhhru Config constructed via Config.from_args at call site inside background worker, bypassing web-app factory - #51
Conversation
…te inside background worker, bypassing web-app factory
| job.progress = "Analyzing repository structure..." | ||
|
|
||
| # Create config for documentation generation (using env vars) | ||
| import argparse |
There was a problem hiding this comment.
🦩 🔴 Config constructed via Config.from_args at call site inside background worker, bypassing web-app factory
In _process_job, replaced the argparse.Namespace + Config.from_args workaround and post-construction config.docs_dir mutation with a call to a new Config.from_web_job(repo_path=temp_repo_dir, docs_dir=docs_dir) classmethod factory, removing the now-unused import argparse. This change assumes such a factory will be added to codewiki/src/config.py, which is outside this file and was not provided — without adding from_web_job to the Config class, this file will raise AttributeError at runtime. A complete fix requires adding the Config.from_web_job classmethod in codewiki/src/config.py mirroring from_args's validation logic but accepting an explicit docs_dir parameter instead of mutating it post-hoc.
🤖 Prompt for AI agents
In codewiki/src/fe/background_worker.py around line 207, review and complete this code-review fix: Config constructed via Config.from_args at call site inside background worker, bypassing web-app factory.
What the draft fix changed: In `_process_job`, replaced the `argparse.Namespace` + `Config.from_args` workaround and post-construction `config.docs_dir` mutation with a call to a new `Config.from_web_job(repo_path=temp_repo_dir, docs_dir=docs_dir)` classmethod factory, removing the now-unused `import argparse`. This change assumes such a factory will be added to `codewiki/src/config.py`, which is outside this file and was not provided — without adding `from_web_job` to the `Config` class, this file will raise `AttributeError` at runtime. A complete fix requires adding the `Config.from_web_job` classmethod in `codewiki/src/config.py` mirroring `from_args`'s validation logic but accepting an explicit `docs_dir` parameter instead of mutating it post-hoc.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.
fix confidence: 🔴 45 low — review closely — react 👍/👎 to teach the reviewer
|
Blocking: config = Config.from_web_job(repo_path=temp_repo_dir, docs_dir=docs_dir)
The intent is right — building a Note #52 has since merged and also touches |
The branch replaced the background worker's fake-argparse.Namespace dance with Config.from_web_job(...), but that classmethod did not exist on Config (only from_args, from_cli and from_config_manager), so _process_job raised AttributeError on the first job. Add it, delegating to from_args for the environment-driven resolution and then applying the job-specific docs_dir - behaviourally identical to the three lines it replaces. Also merges main; the background_worker cleanup log line conflicted with #40's print -> logging conversion and is resolved in favour of main. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Closes findings from rule CODEWIKI-007 — Config constructed via Config.from_args at call site inside background worker, bypassing web-app factory.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
codewiki/src/fe/background_worker.py:207What 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:
2cc7a212-e9ac-481a-a76e-5f03d762c00cMerging 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-86akbhhru CodeWiki backend and CLI review findings (12 PRs)