Skip to content

fix(adhoc-sweep-fixes): CU-17tkuw5uezv 2 review findings across 2 files - #117

Draft
flamingo[bot] wants to merge 2 commits into
mainfrom
ai-fix/adhoc-sweep-fixes-7a952aa6-c0f6ce38
Draft

flamingo[bot] wants to merge 2 commits into
mainfrom
ai-fix/adhoc-sweep-fixes-7a952aa6-c0f6ce38

Conversation

@flamingo

@flamingo flamingo Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Closes 2 review findings across 2 files.

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 🟡 78 medium create_main_model / create_fallback_model build unused default_headers dict and never attach it to the provider codewiki/src/be/llm_services.py:118
2 🟢 97 high flake8() invokes subprocess.run with shell=True and unsanitized file_path interpolation codewiki/src/be/agent_tools/str_replace_editor.py:187

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: c0f6ce38-9374-4249-ab94-7ff9724ef5e6

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-17tkuw5uezv CodeWiki review findings sweep (1 PRs)

@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

2 finding(s) fixed in this draft — 2 explained inline on the diff.

"Or in config file: main_base_url = '<url>'"
)

# Prepare default headers for API version (Anthropic models)

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.

🦩 🟠 create_main_model / create_fallback_model build unused default_headers dict and never attach it to the provider

In create_main_model, create_fallback_model, and create_cluster_model the previously-dead default_headers dict is now actually used: when *_api_version is set, an AsyncOpenAI client is constructed with default_headers={'anthropic-version': api_version} and passed to OpenAIProvider(openai_client=...), per the comment that was already in the code; otherwise the provider is built with base_url=/api_key= as before. Added AsyncOpenAI to the existing from openai import ... line (module already exists as a dependency, no new import added). Unverified: exact OpenAIProvider(openai_client=...) signature/behavior across pydantic-ai versions beyond what the existing comment asserted; if openai_client= also requires/forbids other params in some pydantic-ai release, this could need adjustment, but it directly implements the fix the comment itself specified.

🤖 Prompt for AI agents
In codewiki/src/be/llm_services.py around line 118, review and complete this code-review fix: create_main_model / create_fallback_model build unused default_headers dict and never attach it to the provider.
What the draft fix changed: In `create_main_model`, `create_fallback_model`, and `create_cluster_model` the previously-dead `default_headers` dict is now actually used: when `*_api_version` is set, an `AsyncOpenAI` client is constructed with `default_headers={'anthropic-version': api_version}` and passed to `OpenAIProvider(openai_client=...)`, per the comment that was already in the code; otherwise the provider is built with `base_url=`/`api_key=` as before. Added `AsyncOpenAI` to the existing `from openai import ...` line (module already exists as a dependency, no new import added). Unverified: exact `OpenAIProvider(openai_client=...)` signature/behavior across pydantic-ai versions beyond what the existing comment asserted; if `openai_client=` also requires/forbids other params in some pydantic-ai release, this could need adjustment, but it directly implements the fix the comment itself specified.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 78 medium — react 👍/👎 to teach the reviewer

Comment on lines 188 to 196
"""Run flake8 on a given file and return the output as a string"""
if Path(file_path).suffix != ".py":
return ""
cmd = "flake8 --isolated --select=F821,F822,F831,E111,E112,E113,E999,E902 {file_path}"
cmd = ["flake8", "--isolated", "--select=F821,F822,F831,E111,E112,E113,E999,E902", file_path]
# don't use capture_output because it's not compatible with python3.6
out = subprocess.run(cmd.format(file_path=file_path), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = subprocess.run(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return out.stdout.decode()


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.

🦩 🟠 flake8() invokes subprocess.run with shell=True and unsanitized file_path interpolation

In flake8(), replaced the shell-interpolated string command (cmd.format(file_path=file_path) run with shell=True) with a list-of-args command (["flake8", "--isolated", "--select=...", file_path]) run with shell=False. This eliminates the command injection vector since file_path is now passed as a single discrete argv element rather than being interpolated into a shell-parsed string, matching the suggested fix exactly. The unrelated view() method's subprocess.run(..., shell=True) for find was left untouched since it was not part of this finding's evidence/scope.

🤖 Prompt for AI agents
In codewiki/src/be/agent_tools/str_replace_editor.py around line 187, review and complete this code-review fix: flake8() invokes subprocess.run with shell=True and unsanitized file_path interpolation.
What the draft fix changed: In `flake8()`, replaced the shell-interpolated string command (`cmd.format(file_path=file_path)` run with `shell=True`) with a list-of-args command (`["flake8", "--isolated", "--select=...", file_path]`) run with `shell=False`. This eliminates the command injection vector since `file_path` is now passed as a single discrete argv element rather than being interpolated into a shell-parsed string, matching the suggested fix exactly. The unrelated `view()` method's `subprocess.run(..., shell=True)` for `find` was left untouched since it was not part of this finding's evidence/scope.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 97 high — react 👍/👎 to teach the reviewer

@flamingo flamingo Bot changed the title fix(adhoc-sweep-fixes): 2 review findings across 2 files fix(adhoc-sweep-fixes): CU-17tkuw5uezv 2 review findings across 2 files Oct 5, 2026
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.

0 participants