Skip to content

[5416] test(api): Regression and acceptance tests for mounts file/archive endpoints#5455

Open
Yuvakunaal wants to merge 2 commits into
Agenta-AI:mainfrom
Yuvakunaal:fix/5416-mounts-regression-tests
Open

[5416] test(api): Regression and acceptance tests for mounts file/archive endpoints#5455
Yuvakunaal wants to merge 2 commits into
Agenta-AI:mainfrom
Yuvakunaal:fix/5416-mounts-regression-tests

Conversation

@Yuvakunaal

@Yuvakunaal Yuvakunaal commented Jul 23, 2026

Copy link
Copy Markdown

Closes #5416

Summary

The drive/mounts refactor (#5400, refined pre-merge by #5411/#5412) shipped with thin
regression coverage on two behaviors: the archive stream's mtime handling, and the new
file-listing/download-all endpoints. #5416 asked for three things; checking the current
suite showed one of them (_rollup_recent_entries unit tests) already landed in #5411, so
this PR covers the two that were still open.

Unit regression test for the archive mtime bug. StoreObject.mtime is epoch
milliseconds, and stream_mounts_archive converts it via
datetime.fromtimestamp(mtime / 1000, ...). Before that division, a realistic ms-scale
value overflowed datetime.fromtimestamp inside the streaming generator, after the
response's 200 headers were already sent, so the client got a truncated/broken zip with a
success status. The new test stamps a stored file with a realistic epoch-ms mtime, streams
the archive, and unzips the result to check it's byte-correct.

Acceptance coverage for the two endpoints #5400 shipped untested. GET /mounts/{id}/files?depth=1 (the shallow per-directory listing, plus with_counts and
git_aware/include_gitignored), and POST /mounts/files/export (the download-all
archive: prefix folding, source_path scoping, missing-mount 404, path-traversal
rejection, filename in Content-Disposition).

No production code changes. Both additions are test-only, aside from a small additive
set_mtime helper on the existing FakeMountStorage test fake.

Testing

Verified locally

  • Confirmed the mtime regression test actually pins the bug: temporarily reverted the
    /1000 division and watched it fail with ValueError: year 55840 is out of range,
    then restored the fix.
  • pytest oss/tests/pytest/unit/test_mounts_file_ops.py: 51 passed (105 across the full
    mounts unit suite).
  • Stood up the local OSS dev stack (real API + SeaweedFS) and ran
    pytest oss/tests/pytest/acceptance/mounts/: 45 passed, 0 skipped.
  • ruff format + ruff check: clean.

Added or updated tests

  • test_mounts_file_ops.py: new TestArchiveMtimeRegression (1 test) pinning the mtime
    conversion bug.
  • test_mounts_basics.py: new TestMountShallowListing (5 tests) and
    TestMountArchiveExport (6 tests) covering the two previously-untested endpoints.
  • _rollup_recent_entries already has 5 unit tests from fix(api): eager archive errors, capped count-only listing, rollup tests #5411
    (TestRollupRecentEntries), so this PR doesn't touch it.

QA follow-up

N/A — test-only change, no user-visible behavior to QA.

Demo

N/A — not a UI change.

Checklist

  • I have included a video or screen recording for UI changes, or marked Demo as N/A
  • Relevant tests pass locally
  • Relevant linting and formatting pass locally
  • I have signed the CLA, or I will sign it when the bot prompts me

Contributor Resources

…/archive endpoints

Adds a unit regression test pinning the epoch-ms/seconds mtime bug in
stream_mounts_archive, plus acceptance coverage for the shallow (depth=1)
listing and the download-all archive endpoint (/mounts/files/export) —
the two gaps called out in Agenta-AI#5416. _rollup_recent_entries already had
coverage from Agenta-AI#5411, so this PR doesn't touch it.

Closes Agenta-AI#5416
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

@Yuvakunaal is attempting to deploy a commit to the agenta projects Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 23, 2026
@CLAassistant

CLAassistant commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot Bot added the tests label Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds acceptance coverage for shallow mount file listings and bulk archive exports, plus a unit regression test ensuring archive streaming handles epoch-millisecond modification times correctly.

Changes

Mount file endpoint coverage

Layer / File(s) Summary
Shallow listing acceptance coverage
api/oss/tests/pytest/acceptance/mounts/test_mounts_basics.py
Adds reusable file setup and validates depth-one listings, counts, Git-aware filtering, and rejection of unsupported depth values.
Archive export acceptance coverage
api/oss/tests/pytest/acceptance/mounts/test_mounts_basics.py
Validates ZIP contents, path scoping, prefix folding, missing-mount and traversal errors, and custom archive filenames.
Archive timestamp regression coverage
api/oss/tests/pytest/unit/test_mounts_file_ops.py
Extends fake storage with modification times and verifies archive streaming produces valid content for epoch-millisecond timestamps.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • Agenta-AI/agenta#5411: Introduces related archive-streaming and mount listing behavior covered by these tests.
  • Agenta-AI/agenta#5412: Introduces related mount archive export and shallow-listing behavior covered by these tests.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 60.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR covers the archive mtime regression and new mounts endpoint acceptance tests, and notes _rollup_recent_entries was already covered by #5411.
Out of Scope Changes check ✅ Passed The changes stay within the stated test coverage scope, with only a small test fake helper added.
Title check ✅ Passed The title clearly summarizes the main change: regression and acceptance tests for mounts file/archive endpoints.
Description check ✅ Passed The description accurately matches the test-only changes and their scope.
✨ 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.

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a86c4045-cafc-4a1f-8cf4-b2e6e6b5fee0

📥 Commits

Reviewing files that changed from the base of the PR and between 5ceca94 and c41b71b.

📒 Files selected for processing (2)
  • api/oss/tests/pytest/acceptance/mounts/test_mounts_basics.py
  • api/oss/tests/pytest/unit/test_mounts_file_ops.py

Comment thread api/oss/tests/pytest/unit/test_mounts_file_ops.py
Comment thread api/oss/tests/pytest/unit/test_mounts_file_ops.py
Clean up FakeMountStorage._mtimes on delete_keys so a recreated key
can't inherit a stale timestamp. Assert the zip member's converted
date_time explicitly, verified against the real stream_zip output, so
a regression that ignores mtime and falls back to datetime.now() would
still fail this test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(chore) Add regression and acceptance tests for the mounts file and archive endpoints

2 participants