Repository navigation
Add test suite, CI, and a batch of correctness fixes - #6
Merged
Merged
Conversation
The hook and REST endpoint have each needed a bug-fix PR already, with no safety net to catch regressions. This adds one and fixes the small correctness issues found during a repo review: - 50 pytest tests covering the MCP tools, REST endpoint, both auth middlewares, the dashboard, and the finance hook's parsing logic, backed by an in-memory MongoDB (mongomock-motor) so no containers are needed - GitHub Actions workflow running ruff + pytest on every push and PR - Constant-time API key comparison in the MCP/REST bearer auth, matching what the dashboard's basic auth already did - Validate REST body field types with a Pydantic model instead of inserting whatever arrives into Mongo - Clamp list_entries limit/skip (negative values raised from Mongo, and limit was unbounded) - Create indexes on created_at/source/keywords at startup, so list and dashboard queries stop collection-scanning as the store grows - Replace mutable default arguments and a dead `except (InvalidId, Exception)` clause Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3 of 4 tasks
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
mongomock-motor), so tests need no containers and run in under a secondruff check+pyteston every push to main and every PRpyproject.toml(with import sorting and modern-syntax rules); existing code cleaned up to passapp/server.py), matching what the dashboard's basic auth already did withsecrets.compare_digestPOST /entriesnow validates field types via a Pydantic model — previouslydata/keywordsof any type were inserted into Mongo as-islist_entriesclampslimit(1–100) andskip(≥0); negative values previously raised from Mongo andlimitwas unboundedcreated_at,source, andkeywordscreated at server startup, so list/dashboard queries stop collection-scanning as the hook-fed store growskeywords: list[str] = []) replaced withNonedefaultsexcept (InvalidId, Exception)inparse_idnarrowed toexcept (InvalidId, TypeError)so unexpected errors surfaceTest plan
ruff check .— cleanpytest— 50 passed locally against mongomockensure_indexes+ SSE app assembly (mcp.http_app+ REST route + middleware) imports and buildsdocker compose up -d --buildon the CasaOS box and confirm the hook still ingests entries🤖 Generated with Claude Code