Skip to content

Fix #1: [$30 BOUNTY] [Python] Expand backend API contract edge-case tests - #24

Closed
ghost wants to merge 1 commit into
mainfrom
unknown repository
Closed

Fix #1: [$30 BOUNTY] [Python] Expand backend API contract edge-case tests#24
ghost wants to merge 1 commit into
mainfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Jul 26, 2026

Copy link
Copy Markdown

Automated contribution prepared by Atlas 1.

Closes #1

Atlas-Opportunity-Key: #1

Stated reward: $30. Tests and repository validation were run before submission.

Summary by CodeRabbit

  • Tests

    • Added coverage for malformed requests, invalid field types, asynchronous handlers, response handling, propagated errors, and missing handlers.
    • Improved validation of backend message contracts through expanded automated testing.
  • Chores

    • Updated internal development metadata and tooling cache artifacts.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c1ce241-e9ae-4608-988f-c44c5ba7859f

📥 Commits

Reviewing files that changed from the base of the PR and between 2b54872 and 8a83cbb.

⛔ Files ignored due to path filters (1)
  • .aider.tags.cache.v4/cache.db is excluded by !**/*.db
📒 Files selected for processing (4)
  • .aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val
  • .aider.tags.cache.v4/36/7c/0034d7f0946594eca1661e7fef5b.val
  • .aider.tags.cache.v4/f8/ac/0994f2d594fd5159082283840e90.val
  • tests/backend_api/test_api_contract_edge_cases.py

📝 Walkthrough

Walkthrough

Adds isolated pytest coverage for backend API contract edge cases, including validation failures, async handlers, propagated exceptions, and missing handlers. It also replaces three serialized Aider tag cache artifacts.

Changes

Backend API contract tests

Layer / File(s) Summary
Contract validation fixtures and assertions
tests/backend_api/test_api_contract_edge_cases.py
Adds registry and validator fixtures, plus tests for missing and incorrectly typed instrument_ids.
Handler execution and error paths
tests/backend_api/test_api_contract_edge_cases.py
Tests async-wrapper execution, propagated handler exceptions, and unregistered message handling.

Serialized tag cache refresh

Layer / File(s) Summary
Serialized cache payload updates
.aider.tags.cache.v4/...
Replaces opaque cache payloads containing connector and AdminPage.tsx tag metadata.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description omits the required Summary, Changes, Testing, and Checklist sections from the repository template. Rewrite the PR description using the template and fill in the required summary, changes, testing, and checklist details.
Out of Scope Changes check ⚠️ Warning The PR includes unrelated .aider.tags.cache.v4 cache artifact updates, which are outside the backend API test scope. Remove the cache artifact changes unless they are required by the repo workflow and explicitly part of the PR scope.
Linked Issues check ❓ Inconclusive The test additions cover the core edge-case cases, but the exact local-command README/comment update cannot be verified from the summary. Add or surface the README/comment change with the exact local test command so the remaining acceptance criterion can be verified.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: expanding backend API contract edge-case tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request has been flagged as potential spam (bot-spam) by CodeRabbit slop detection and should be reviewed carefully.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
tests/backend_api/test_api_contract_edge_cases.py (1)

76-80: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Narrow the missing-handler exception assertion.

pytest.raises(Exception) can pass for unrelated failures. Assert the concrete exception exposed by the Python binding—or the documented error result if the binding returns one—and retain the expected message check.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/backend_api/test_api_contract_edge_cases.py` around lines 76 - 80,
Update test_missing_handler_returns_error to assert the concrete exception type
exposed by the Python binding, or the documented error result if registry.handle
returns errors instead of raising. Preserve the “No handler registered” message
validation while eliminating the broad pytest.raises(Exception) assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val:
- Line 1: Remove the generated Aider cache entries from
.aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val,
.aider.tags.cache.v4/36/7c/0034d7f0946594eca1661e7fef5b.val, and
.aider.tags.cache.v4/f8/ac/0994f2d594fd5159082283840e90.val, and exclude the
.aider.tags.cache.v4/ directory from version control so runner worktree paths
are not committed; regenerate the cache locally from the current worktree when
needed.

In `@tests/backend_api/test_api_contract_edge_cases.py`:
- Around line 30-43: Update test_malformed_payload_missing_required_field and
test_malformed_payload_wrong_type to assert the complete structured validation
error for instrument_ids, including its exact error code and message, rather
than only checking has_errors() and field presence. Use the validator’s
established error properties and expected contract values while preserving the
existing payload scenarios.
- Around line 59-74: Update test_response_status_and_body_assertions to exercise
the backend API boundary rather than only asserting a returned byte string or
propagated exception. Add at least two malformed or failing request cases and
assert each response’s exact status and structured body, while retaining
coverage of the successful request behavior.

---

Nitpick comments:
In `@tests/backend_api/test_api_contract_edge_cases.py`:
- Around line 76-80: Update test_missing_handler_returns_error to assert the
concrete exception type exposed by the Python binding, or the documented error
result if registry.handle returns errors instead of raising. Preserve the “No
handler registered” message validation while eliminating the broad
pytest.raises(Exception) assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c1ce241-e9ae-4608-988f-c44c5ba7859f

📥 Commits

Reviewing files that changed from the base of the PR and between 2b54872 and 8a83cbb.

⛔ Files ignored due to path filters (1)
  • .aider.tags.cache.v4/cache.db is excluded by !**/*.db
📒 Files selected for processing (4)
  • .aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val
  • .aider.tags.cache.v4/36/7c/0034d7f0946594eca1661e7fef5b.val
  • .aider.tags.cache.v4/f8/ac/0994f2d594fd5159082283840e90.val
  • tests/backend_api/test_api_contract_edge_cases.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 3

🧹 Nitpick comments (1)
tests/backend_api/test_api_contract_edge_cases.py (1)

76-80: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Narrow the missing-handler exception assertion.

pytest.raises(Exception) can pass for unrelated failures. Assert the concrete exception exposed by the Python binding—or the documented error result if the binding returns one—and retain the expected message check.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/backend_api/test_api_contract_edge_cases.py` around lines 76 - 80,
Update test_missing_handler_returns_error to assert the concrete exception type
exposed by the Python binding, or the documented error result if registry.handle
returns errors instead of raising. Preserve the “No handler registered” message
validation while eliminating the broad pytest.raises(Exception) assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val:
- Line 1: Remove the generated Aider cache entries from
.aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val,
.aider.tags.cache.v4/36/7c/0034d7f0946594eca1661e7fef5b.val, and
.aider.tags.cache.v4/f8/ac/0994f2d594fd5159082283840e90.val, and exclude the
.aider.tags.cache.v4/ directory from version control so runner worktree paths
are not committed; regenerate the cache locally from the current worktree when
needed.

In `@tests/backend_api/test_api_contract_edge_cases.py`:
- Around line 30-43: Update test_malformed_payload_missing_required_field and
test_malformed_payload_wrong_type to assert the complete structured validation
error for instrument_ids, including its exact error code and message, rather
than only checking has_errors() and field presence. Use the validator’s
established error properties and expected contract values while preserving the
existing payload scenarios.
- Around line 59-74: Update test_response_status_and_body_assertions to exercise
the backend API boundary rather than only asserting a returned byte string or
propagated exception. Add at least two malformed or failing request cases and
assert each response’s exact status and structured body, while retaining
coverage of the successful request behavior.

---

Nitpick comments:
In `@tests/backend_api/test_api_contract_edge_cases.py`:
- Around line 76-80: Update test_missing_handler_returns_error to assert the
concrete exception type exposed by the Python binding, or the documented error
result if registry.handle returns errors instead of raising. Preserve the “No
handler registered” message validation while eliminating the broad
pytest.raises(Exception) assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c1ce241-e9ae-4608-988f-c44c5ba7859f

📥 Commits

Reviewing files that changed from the base of the PR and between 2b54872 and 8a83cbb.

⛔ Files ignored due to path filters (1)
  • .aider.tags.cache.v4/cache.db is excluded by !**/*.db
📒 Files selected for processing (4)
  • .aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val
  • .aider.tags.cache.v4/36/7c/0034d7f0946594eca1661e7fef5b.val
  • .aider.tags.cache.v4/f8/ac/0994f2d594fd5159082283840e90.val
  • tests/backend_api/test_api_contract_edge_cases.py
🛑 Comments failed to post (3)
.aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val (1)

1-1: 🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== repo files matching aider tags cache =="
git ls-files | grep -F '\.aider.tags.cache.v4' || true

echo
echo "== target cache files via find (readable only if tracked/exist) =="
for f in .aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val \
         .aider.tags.cache.v4/36/7c/0034d7f0946594eca1661e7fef5b.val \
         .aider.tags.cache.v4/f8/ac/0994f2d594fd5159082283840e90.val; do
  if [ -f "$f" ]; then
    echo "--- $f"
    python3 - <<'PY' "$f"
import pickletools, pickle, sys
path=sys.argv[1]
with open(path,'rb') as f: data=f.read()
print("bytes:", len(data))
try:
    obj=pickle.loads(data)
    print("class:", obj.__class__ if hasattr(obj,'__class__') else type(obj).__name__)
    print("repr:", repr(obj)[:1200])
    if hasattr(obj, '__dict__'):
        print("dict:", obj.__dict__)
except Exception as e:
    print("load_error:", e)
try:
    out=[]
    pickletools.dis(data, out=out)
    print("pickle_output:")
    print(''.join(line.decode('utf-8','replace') for line in out[:250]))
except Exception as e:
    print("dis_error:", e)
PY
  else
    echo "--- MISSING: $f"
  fi
done

echo
echo "== config references to aider ignore/cache/gitignore =="
git ls-files | xargs -r rg -n -g '!.aider*.cache*' -g '!*' '\.aider|tags\.cache|gitignore|ignore' | head -200 || true

echo
echo "== current aider docs/config if present =="
git ls-files | xargs -r rg -n -g '!.aider*.cache*' -g '!*' 'tags\.cache|aider|\.aider' | head -200 || true

Repository: jackjin1997/zeroeye

Length of output: 4562


🌐 Web query:

aider repomap tags cache v4 absolute filename modified time .aider.tags.cache.v4

💡 Result:

The.aider.tags.cache.v4 directory is a versioned local cache used by Aider to store indexed symbol tags and repository map data [1][2]. By caching this information on disk, Aider avoids the need to re-parse and re-analyze unchanged source files every time it generates a repository map, significantly improving performance [3][2]. Key details about.aider.tags.cache.v4: - Function: It acts as an underlying storage mechanism—typically using an SQLite-based database (via diskcache)—for the repository map [4]. It stores critical identifiers (classes, functions, methods, etc.) and their definitions to help the LLM understand the codebase [3][4]. - Versioning: The v4 suffix indicates a specific schema or version of the cache format [1]. Aider increments this version number when the cache structure changes, meaning older versions (like v3) are not compatible [5][2]. - Location: By default, this directory is created in the root of the Git repository where Aider is running [5][4]. - Customization: To prevent cluttering the repository or to resolve issues (such as file locking on network drives or CIFS mounts), you can change the location of this directory using the map-tags-cache-dir configuration option or the MAP_TAGS_CACHE_DIR environment variable [6][7]. If Aider encounters issues accessing this directory (e.g., due to permissions, network storage locks, or read-only file systems), it will typically log a warning and fall back to using an in-memory cache, which may result in slower startup times for large repositories [8][7].

Citations:


🌐 Web query:

site:github.com/paul-gauthier/aider "map-tags-cache-dir" "modified time" "mtime" ".aider.tags.cache.v4"

💡 Result:

The directory .aider.tags.cache.v4 (and similar versions like v3) is a cache directory created by Aider to store repository map data [1][2]. The modification time (mtime) of files within this directory is used by Aider to determine if the cached tags for a specific file remain valid [1][2]. Specifically: 1. Aider compares the current file modification time (obtained via os.path.getmtime) of a source file with the mtime stored in the cache [1][2]. 2. If the mtime in the cache matches the file's current mtime, Aider uses the cached tags data to avoid re-parsing the file [1][2]. 3. If the mtime values differ, or if the file is not in the cache, Aider re-parses the file to generate fresh tag data and updates the cache with the new mtime and data [1][2]. If you encounter issues such as database errors or unexpected behavior related to the repository map, it is common troubleshooting advice to delete the .aider.tags.cache.v* directory while Aider is not running, which forces Aider to regenerate the cache [3][4][5].

Citations:


🌐 Web query:

Aider repomap cache key absolute path getmtime mtime .aider.tags.cache.v4

💡 Result:

In Aider, the.aider.tags.cache.v4 directory serves as a persistent, file-based cache used to store symbol tags, which accelerates the generation of the repository map [1][2][3]. Key technical details regarding this cache include: Cache Key and Logic: Aider uses the absolute path of a file as the primary cache key (cache_key = fname) within the SQLite-backed database (typically managed via the diskcache library) [1][4][3]. Cache Validation (mtime): To ensure the cached data for a file is still valid, Aider compares the current file modification time (mtime), retrieved using os.path.getmtime(fname), with the mtime stored in the cache entry [1][4]. - When Aider checks a file's tags, it retrieves the stored mtime from the database. - If the current mtime matches the cached mtime, Aider returns the cached tag data [4]. - If the mtimes differ (indicating the file has changed) or if the file is not in the cache, Aider re-parses the file and updates the cache with the new tag data and the updated mtime [4]. Configuration: While the cache directory defaults to.aider.tags.cache.v4 within the root of the repository, its location can be customized using the map-tags-cache-dir configuration option (or formerly via map-cache-dir in some versions) [5][6]. This is particularly useful for avoiding issues with network file systems (like CIFS) where database locking may occur, or to keep the repository directory clean [5][6].

Citations:


Do not commit Aider tag cache entries containing runner worktree paths.

These cached payloads reference /home/runner/work/..., and Aider cache entries are keyed by the source-file path with validation against the current file mtime. Local checkouts for this worktree will miss those keys and rebuild the cache; keep .aider.tags.cache.v4/ out of the repository and regenerate it from the current Aider worktree when needed.

📍 Affects 3 files
  • .aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val#L1-L1 (this comment)
  • .aider.tags.cache.v4/36/7c/0034d7f0946594eca1661e7fef5b.val#L1-L1
  • .aider.tags.cache.v4/f8/ac/0994f2d594fd5159082283840e90.val#L1-L1
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val at line 1,
Remove the generated Aider cache entries from
.aider.tags.cache.v4/04/3d/9784de302b0d530520ef94deaa61.val,
.aider.tags.cache.v4/36/7c/0034d7f0946594eca1661e7fef5b.val, and
.aider.tags.cache.v4/f8/ac/0994f2d594fd5159082283840e90.val, and exclude the
.aider.tags.cache.v4/ directory from version control so runner worktree paths
are not committed; regenerate the cache locally from the current worktree when
needed.
tests/backend_api/test_api_contract_edge_cases.py (2)

30-43: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the complete structured validation error.

These tests only verify that an error exists and mention the expected field. Assert the exact error code and message for the missing-field and wrong-type cases; otherwise incorrect contract responses can still pass.

🧰 Tools
🪛 ast-grep (0.44.1)

[info] 31-31: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"types": ["tick"]})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


[info] 39-39: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"instrument_ids": "not-a-list", "types": ["tick"]})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/backend_api/test_api_contract_edge_cases.py` around lines 30 - 43,
Update test_malformed_payload_missing_required_field and
test_malformed_payload_wrong_type to assert the complete structured validation
error for instrument_ids, including its exact error code and message, rather
than only checking has_errors() and field presence. Use the validator’s
established error properties and expected contract values while preserving the
existing payload scenarios.

59-74: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Cover the actual response contract and two negative cases.

This test does not assert a response status or structured body, and it contains only one negative case. Exercise the backend API boundary and assert the exact status/body for at least two malformed or failing requests.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/backend_api/test_api_contract_edge_cases.py` around lines 59 - 74,
Update test_response_status_and_body_assertions to exercise the backend API
boundary rather than only asserting a returned byte string or propagated
exception. Add at least two malformed or failing request cases and assert each
response’s exact status and structured body, while retaining coverage of the
successful request behavior.

@ghost ghost closed this by deleting the head repository Jul 31, 2026
This pull request was closed.
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.

[$30 BOUNTY] [Python] Expand backend API contract edge-case tests

1 participant