fix: Notion not-connected crashes + test suite reliability - #13
Open
0xSY3 wants to merge 5 commits into
Open
Conversation
- app/tools/notion.py: _notion_request returns {"success": False, "error":
"Notion not connected..."} when no token instead of raising ValueError,
matching the graceful-degradation contract every other tool follows
- tests: fix AsyncMock pool-race assertions (MagicMock has no await_count)
- tests: _connect_client made async context manager so patch stays active
during ASGI requests (was exiting before first DB call)
- tests: publish_page mocks switched from sys.modules patch to direct
patch("app.services.pages_agent.create_page") — sys.modules bypass fails
when module already imported earlier in suite
206 passed, 0 failed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Caddy runs in ~/memory-layer stack (production data: 27 users). ~/zynd was a dead-end second copy that previous deploys incorrectly targeted. All future `make deploy` / `make ship` now hit the live stack. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
POST /context/{user_id} and GET /users/{user_id}/graph were 403ing for
all agent-persona users because current_user() translates a Supabase UUID
to the internal memory-layer ID, but the path param check compared the
raw Supabase UUID against the translated ID — they never matched.
Result: ingest worked (no path param check) but context reads silently
failed, so the agent had no memory on every turn even though data was
being saved.
Fix: query with auth_user (already resolved by current_user) instead of
the path param user_id.
Passing a different user_id in the path now returns the caller's own
graph (200) instead of 403 — the path param is ignored in favor of
auth_user. Assert the returned data matches the direct /users/{uid}/graph
call to verify no cross-user leakage.
Same Supabase UUID → internal ID mismatch as the context/graph fix. All path-param endpoints that compare user_id == auth_user now use auth_user directly for queries so callers with mapped Supabase UUIDs are never blocked with a false 403.
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.
Summary
_notion_requestwas raisingValueErrorwhen Notion isn't connected, propagating unhandled through all Notion tools (search_notion,create_notion_page, etc.). Now returns{"success": False, "error": "Notion not connected..."}— consistent with every other OAuth tool.patch(..., side_effect=async_fn)creates aMagicMockwith noawait_counttracking. Switched tonew_callable=AsyncMockso the assertion works correctly._connect_clientwas a plain function that exited thepatch("app.connect.get_pool", ...)context before any HTTP request was made. Converted to@asynccontextmanagerso the patch stays alive.patch.dict("sys.modules", ...)is bypassed whenapp.services.pages_agentis already imported earlier in the suite (module attribute takes precedence). Switched topatch("app.services.pages_agent.create_page", ...).Test plan
pytest tests/ -q)🤖 Generated with Claude Code