Skip to content

fix: report invalid office uploads - #219

Merged
EricNGOntos merged 2 commits into
mainfrom
fix/wangbinqi/invalid-file-job-response
Jul 24, 2026
Merged

fix: report invalid office uploads#219
EricNGOntos merged 2 commits into
mainfrom
fix/wangbinqi/invalid-file-job-response

Conversation

@suguanYang

Copy link
Copy Markdown
Contributor

Summary

  • Added worker-side OOXML container validation before parser dispatch for .docx, .xlsx, and .pptx uploads, returning INVALID_ARGUMENT for malformed Office containers instead of surfacing BadZipFile.
  • Updated job response projection so failed or refunded jobs report credits_spent: 0.0.
  • Refreshed sync-state Redis job metadata with persisted error_details after failure handling, so clients see the invalid-file reason promptly.
  • Related task: invalid Office uploads should be client-visible as invalid files and spend zero credits.

Verification

  • uv run --python 3.11 --package knowhere-worker-app --group dev pytest apps/worker/tests/contract/test_parse_task_contract.py -q
  • uv run --python 3.11 --package knowhere-api-app --group dev pytest apps/api/tests/contract/test_job_read_contract.py -q
  • uv run --python 3.11 ruff check apps/api/app/services/jobs/result_projection.py apps/api/tests/contract/test_job_read_contract.py apps/worker/app/services/document_parser/orchestration/office_container_validator.py apps/worker/app/services/document_parser/orchestration/route_parse.py apps/worker/tests/contract/test_parse_task_contract.py packages/shared-python/shared/core/state_machine/service_sync.py
  • make typecheck
  • make lint
  • No manual API smoke test was run; API and worker behavior is covered by contract tests plus lint/typecheck.

Deployment Notes

  • No new or changed environment variables.
  • No database migrations.
  • Queue and storage behavior are unchanged except invalid OOXML files now fail earlier with ValidationException; the refund path remains zero-charge for failed jobs.
  • Rollback restores the previous BadZipFile/UnknownException behavior for malformed Office uploads.

Checklist

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

@EricNGOntos
EricNGOntos merged commit 53fd990 into main Jul 24, 2026
6 checks passed
@EricNGOntos
EricNGOntos deleted the fix/wangbinqi/invalid-file-job-response branch July 24, 2026 14:41
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