fix(claude): repair the broken test file and add the endpoints it imports - #289
Open
fig-ai-agent[bot] wants to merge 1 commit into
Open
fix(claude): repair the broken test file and add the endpoints it imports#289fig-ai-agent[bot] wants to merge 1 commit into
fig-ai-agent[bot] wants to merge 1 commit into
Conversation
…orts
tests/test_claude_endpoints.py was chat prose wrapped around a fenced code
block, so tests/ failed collection repo-wide with
'SyntaxError: invalid character (U+2192)'. Extracted the real code, fixed two
assertion bugs in it, and added the module it imports but that never existed.
New:
- app/services/claude_client.py httpx-based Claude client (stream + send)
- app/api/v1/endpoints/claude.py POST /claude/chat/stream, /claude/chat/tools, GET /claude/status
Fixed (pre-existing, both blocked any import of app.services):
- app/services/__init__.py imported UserService, which users.py never defined;
now resolves lazily so one broken downstream module no longer takes out the
whole package
- app/core/config.py Settings() raised on the repo's own .env (undeclared
keys + required OAUTH_CLIENT_ID); extra=ignore and a default
Verified: 4/4 pass; tests/ collection errors 10 -> 5, no new ones.
The 5 remaining are pre-existing and unrelated.
Note: app/.gitignore's 'service*' rule would silently exclude the new client
module, so it is force-added.
This was referenced Sep 14, 2026
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.
What this fixes
tests/test_claude_endpoints.py(added in #241, commit3702790) is chat prose wrapped around a fenced code block, not Python. It fails to even parse:Because pytest imports every file under
tests/, that one file broke collection for the whole directory — every valid test beside it was blocked. This PR repairs it and supplies the module it imports but that never existed.New files
app/services/claude_client.pystream_message()yields decoded SSE frames,send_message()returns the full body. No new SDK dependency.app/api/v1/endpoints/claude.pyPOST /claude/chat/stream(SSE),POST /claude/chat/tools(tool-calling),GET /claude/statusPre-existing breakage fixed (both blocked any import of
app.services)app/services/__init__.pydidfrom .users import UserService—UserServicedoes not exist inusers.py(it definesUserRepo). A package__init__runs before any submodule import, so this madeapp.services.*app.main-blocking. Now resolves lazily (PEP 562), so one broken downstream module can no longer take out the whole package.app/core/config.py—Settings()raised on the repo's own.env: undeclared keys (WHATSAPP_*,BYTEPLUS_*, …) plus a requiredOAUTH_CLIENT_ID. Addedextra = "ignore"and a default.Verification
Collection errors across
tests/, vs. untouchedorigin/main:origin/mainNo regressions — every remaining error is present on
mainunchanged (commdiff of the two error sets). Five fixed, ten new tests collected.Two things worth your eye
app/.gitignorecontains a bareservice*rule that ignores anything underapp/services/. The new client module would have been silently dropped, so it is force-added (git add -f). That rule looks like an accident — worth deleting separately.lines == 'data: {...}'compared alistto astr(and would still be wrong even if the types matched), andtool_calls["name"]indexed a list. The endpoint also emitteddata: "[DONE]"(JSON-quoted) instead of the bare SSE sentinel.Not included on purpose:
app/db/repositories.pyis also broken (AsyncSession/Itemundefined — 5 of the remaining collection errors). It is unrelated to this deliverable and belongs in its own PR.