Skip to content

fix(CODEWIKI-007): CU-86akbhhru Config constructed via Config.from_args at call site inside background worker, bypassing web-app factory - #51

Merged
michaelassraf merged 3 commits into
mainfrom
ai-fix/codewiki-007-bb8aa464-2cc7a212
Sep 8, 2026
Merged

michaelassraf merged 3 commits into
mainfrom
ai-fix/codewiki-007-bb8aa464-2cc7a212

Conversation

@flamingo

@flamingo flamingo Bot commented Sep 7, 2026

Copy link
Copy Markdown

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.

# Fix confidence Finding Location
1 🔴 45 low — review closely Config constructed via Config.from_args at call site inside background worker, bypassing web-app factory codewiki/src/fe/background_worker.py:207

What 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-5f03d762c00c

Merging 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)

…te inside background worker, bypassing web-app factory

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 What this fix changed, finding by finding

1 finding(s) fixed in this draft — 1 explained inline on the diff; 1 low-confidence hunk(s) need close review before merging.

job.progress = "Analyzing repository structure..."

# Create config for documentation generation (using env vars)
import argparse

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🔴 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

@flamingo flamingo Bot changed the title fix(CODEWIKI-007): Config constructed via Config.from_args at call site inside background worker, bypassing web-app factory fix(CODEWIKI-007): CU-86akbhhru Config constructed via Config.from_args at call site inside background worker, bypassing web-app factory Sep 7, 2026
@michaelassraf

Copy link
Copy Markdown

Blocking: Config.from_web_job does not exist.

config = Config.from_web_job(repo_path=temp_repo_dir, docs_dir=docs_dir)

Config defines only from_args, from_cli, and from_config_manager. I checked main and every branch in this batch (including #39 and #49, the other two that touch config.py) — nothing adds from_web_job. This is an AttributeError on the first job the web-app background worker processes.

The intent is right — building a Config through a fake argparse.Namespace at a call site is the thing worth fixing. Please add the from_web_job classmethod to codewiki/src/config.py in this PR.

Note #52 has since merged and also touches background_worker.py, so this will need a rebase.

michaelassraf and others added 2 commits September 7, 2026 22:45
Bring the branch up to date with main (PRs #48, #49, #52, #53, #54, #55).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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>
@michaelassraf
michaelassraf marked this pull request as ready for review September 8, 2026 02:58
@michaelassraf
michaelassraf merged commit c0a043b into main Sep 8, 2026
@michaelassraf
michaelassraf deleted the ai-fix/codewiki-007-bb8aa464-2cc7a212 branch September 8, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant