Skip to content

test: lock oversized PDF rejection policy branches - #416

Open
Frankie-Xu wants to merge 1 commit into
Ontos-AI:mainfrom
Frankie-Xu:test/Frankie-Xu/oversized-pdf-policy-lock
Open

Frankie-Xu wants to merge 1 commit into
Ontos-AI:mainfrom
Frankie-Xu:test/Frankie-Xu/oversized-pdf-policy-lock

Conversation

@Frankie-Xu

@Frankie-Xu Frankie-Xu commented Sep 14, 2026

Copy link
Copy Markdown

Related to #121.

Summary

  • Add worker unit coverage for oversized_pdf_policy.py. That module is the billing/admission gate for oversized PDFs and previously had no direct tests.
  • Test-only. No production code, copy, or policy behavior change.
  • Uses mocked MAX_PDF_PAGE_LIMIT / OVERSIZED_PDF_SHARD_ENABLED / OVERSIZED_PDF_SOFT_LIMIT (no real large PDFs).

Covered branches:

  • non-PDF files are not rejected
  • PDFs at or below MAX_PDF_PAGE_LIMIT are not rejected
  • OVERSIZED_PDF_SHARD_ENABLED=false and pages above the direct limit → ValidationException
  • sharding enabled and pages at or below OVERSIZED_PDF_SOFT_LIMIT → admitted
  • pages above the soft limit → contact-support rejection
  • shard/profile failures expose user_message + reason, and keep internal_message off to_client()

This does not implement #121 productionization (shard pipeline / 300MB upload). It only locks the current rejection policy.

Verification

  • make lint — All checks passed
  • make typecheck — 0 errors, 0 warnings, 0 informations
  • cd apps/worker && uv run pytest -p no:postgresql tests/unit/test_oversized_pdf_policy.py -q — 7 passed

-p no:postgresql is only to skip the autoloaded pytest-postgresql plugin in this environment (no libpq). The tests do not use Postgres.

Deployment Notes

  • No new or changed environment variables
  • No database migrations, queue changes, storage changes, or release-order requirements
  • Backwards compatible; rollback is reverting this PR

Checklist

  • Tests were added or updated when behavior changed
  • Public docs, examples, or OpenAPI contracts were updated when needed — N/A (test-only)
  • Database migrations are idempotent and safe to deploy — N/A
  • Logs, errors, and validation paths avoid leaking secrets or user data
  • The pull request description explains any breaking or user-visible change — none

Add unit coverage for oversized_pdf_policy.py so billing/admission
decisions stay locked without changing production behavior.

Co-authored-by: Frankie-Xu <Frankie-Xu@users.noreply.github.com>
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.

2 participants