Skip to content

chore(doc-transformation): Remove Unused document transformation module - #1428

Open
Ayush8923 wants to merge 1 commit into
chore/remove-openai-conversationsfrom
chore/remove-doc-transformation
Open

Ayush8923 wants to merge 1 commit into
chore/remove-openai-conversationsfrom
chore/remove-doc-transformation

Conversation

@Ayush8923

@Ayush8923 Ayush8923 commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Closes #1382

What Changed

  • target_format, transformer, callback_url form fields removed from POST /documents. transformation_job removed from DocumentUploadResponse.
  • GET /documents/transformation/{job_id} and GET /documents/transformation routes removed, along with DocTransformationJobCrud, DocTransformationJob and the related public models.
  • Migration 096 drops the doc_transformation_job table and the transformationstatus enum. document.source_document_id is kept, so existing transformed documents stay listable.
  • Removed services/doctransform/ (Zerox transformer and registry), the run_doctransform_job and start_doctransform_job Celery task and helper, and the doc-transformation pending-job monitor. Also removed DOC_TRANSFORMATION_PENDING_THRESHOLD_MINUTES, plus OPENAI_API_KEY from the .env examples.
  • get_file_format moved from services/doctransform/registry to services/documents/formats. validate_upload now returns str instead of (source_format, transformer).

Summary

Upload call tree:

 upload_doc
-  validate_callback_url
-  validate_upload(src, target_format, transformer)
-    pre_transform_validation
+  validate_upload(src)
+    get_file_format          # 422 on unknown extension
+    validate_document_content
   storage.put
   DocumentCrud.update
-  schedule_transformation
-    DocTransformationJobCrud.create
-    transformation_job.start_job
-      start_doctransform_job → run_doctransform_job
   DocumentUploadResponse

File layout:

 backend/app/
 ├── api/routes/
-│   └── doc_transformation_job.py
 ├── crud/document/
-│   └── doc_transformation_job.py
 ├── models/
-│   └── doc_transformation_job.py
 ├── services/
-│   ├── doctransform/          # job, registry, transformer, zerox_transformer
 │   └── documents/
+│       └── formats.py         # extension → format map, get_file_format
 └── alembic/versions/
+    └── 096_drop_doc_transformation_job_table.py

Evidence

No test run output is attached. The diff updates these assertions:

  • Before: test_upload_without_transformation asserts response.data["transformation_job"] is None.
    After: test_upload_basic, test_upload_json and test_upload_response_structure assert "transformation_job" not in response.data.
  • Before: validate_upload(...) returns ("csv", None).
    After: test_valid_csv_returns_format asserts validate_upload(src=...) == "csv". The new test_unsupported_extension_raises_http_422 asserts a 422 with "Unsupported file extension: .xyz".
  • Before: test_monitor_pending_jobs_reports_stale_pending_rows expects total_stale_pending == 4 and 3 Sentry events, including doc_transformation_job.
    After: It expects total_stale_pending == 3 and 2 events (job, collection_jobs).
  • get_file_format tests moved from tests/services/doctransformer/test_registry.py to the new tests/services/documents/test_formats.py.

Merge Danger

Door: one-way

Migration 096 runs DROP TABLE doc_transformation_job and DROP TYPE transformationstatus. All job rows are lost on upgrade. downgrade() only recreates the empty schema so older code can boot. It does not restore the data. The code removal is revertable, but the job history is not.

Blast Radius: API consumers

  • Clients that poll /documents/transformation/... will now get 404.
  • Clients that send target_format to POST /documents will no longer get a transformation, and the response has no transformation_job key.
  • Any in-flight run_doctransform_job Celery tasks queued at deploy time will fail: the task is unregistered and its table is gone.
  • This PR is stacked on chore/remove-openai-conversations, so it should merge after that branch.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Previous PR description

Issue

Closes #1382

Summary

  • Removed the document transformation Module which is not used anymore.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Remove the doctransform service (Zerox pdf->markdown), the
/documents/transformation endpoints, the transformation options on
document upload, the Celery task and starter, pending-job monitoring
for doc_transformation_job and its config/env settings, docs and tests.
The extension-to-format map moves to services/documents/formats.py.

Migration 096 drops doc_transformation_job and its enum type.
document.source_document_id is kept so existing transformed documents
stay listable.
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 953eeec and b9453cd.

Files selected for processing: 55

  • .claude/conventions/celery.md
  • .claude/conventions/service.md
  • .env.example
  • .env.test.example
  • CLAUDE.md
  • backend/app/alembic/versions/096_drop_doc_transformation_job_table.py
  • backend/app/api/docs/documents/job_info.md
  • backend/app/api/docs/documents/job_list.md
  • backend/app/api/docs/documents/permanent_delete.md
  • backend/app/api/docs/documents/upload.md
  • backend/app/api/docs/documents/v2/register.md
  • backend/app/api/main.py
  • backend/app/api/routes/doc_transformation_job.py
  • backend/app/api/routes/documents/document.py
  • backend/app/celery/tasks/job_execution.py
  • backend/app/celery/utils.py
  • backend/app/core/config.py
  • backend/app/core/telemetry/context.py
  • backend/app/crud/__init__.py
  • backend/app/crud/document/doc_transformation_job.py
  • backend/app/crud/job/__init__.py
  • backend/app/crud/job/pending_monitor.py
  • backend/app/models/__init__.py
  • backend/app/models/doc_transformation_job.py
  • backend/app/models/document.py
  • backend/app/services/doctransform/job.py
  • backend/app/services/doctransform/registry.py
  • backend/app/services/doctransform/transformer.py
  • backend/app/services/doctransform/zerox_transformer.py
  • backend/app/services/documents/formats.py
  • backend/app/services/documents/helpers.py
  • backend/app/services/documents/registration.py
  • backend/app/services/job_monitoring.py
  • backend/app/tests/api/routes/documents/test_route_document_upload.py
  • backend/app/tests/api/routes/test_doc_transformation_job.py
  • backend/app/tests/api/test_auth_failures.py
  • backend/app/tests/celery/test_job_execution.py
  • backend/app/tests/celery/test_utils.py
  • backend/app/tests/core/telemetry/sentry/test_sentry_filters.py
  • backend/app/tests/crud/documents/test_doc_transformation_job.py
  • backend/app/tests/services/doctransformer/test_job/conftest.py
  • backend/app/tests/services/doctransformer/test_job/test_callbacks.py
  • backend/app/tests/services/doctransformer/test_job/test_execute_job.py
  • backend/app/tests/services/doctransformer/test_job/test_execute_job_errors.py
  • backend/app/tests/services/doctransformer/test_job/test_integration.py
  • backend/app/tests/services/doctransformer/test_job/test_start_job.py
  • backend/app/tests/services/doctransformer/test_job/utils.py
  • backend/app/tests/services/doctransformer/test_registry.py
  • backend/app/tests/services/documents/test_formats.py
  • backend/app/tests/services/documents/test_helpers.py
  • backend/app/tests/services/test_job_monitoring.py
  • docs/architecture/kaapi-knowledge-base-ARCHITECTURE.md
  • docs/wiki/INDEX.md
  • docs/wiki/domain-map.md
  • docs/wiki/modules/knowledge-base.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions github-actions Bot changed the title chore(documents): Remove the Document transformation module chore(documents): Remove document transformation module Dec 4, 2026
@Ayush8923
Ayush8923 added this pull request to stack #1432 December 4, 2026 17:34
@Ayush8923
Ayush8923 marked this pull request as ready for review December 4, 2026 17:35
@Ayush8923 Ayush8923 self-assigned this Dec 4, 2026

@claude claude 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.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment on lines 94 to 98
)
async def upload_doc(
session: SessionDep,
current_user: AuthContextDep,
src: UploadFile = File(...),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 (optional) API clients that still send target_format, transformer or callback_url now get a 200 with no transformation and no error. They are not told the feature is gone. The form fields were removed from upload_doc, and FastAPI silently ignores unknown multipart fields. A caller waiting on the callback or on transformation_job hangs or misreads the response. Fix: reject uploads that still carry target_format, transformer or callback_url with a clear 400/410, for example by keeping the fields as optional Form params that raise when set.

Why this was flagged

An existing integration POSTs a pdf to /api/v1/documents with target_format=markdown and callback_url set, as the old upload.md told it to. After this change upload_doc (backend/app/api/routes/documents/document.py:94-98) only declares src. FastAPI drops the extra form fields without complaint, stores the document and returns 200. DocumentUploadResponse no longer has a transformation_job key. On the base branch the same request created a job, returned transformation_job.job_id, and later POSTed to the callback URL. Now the callback never fires and nothing in the response says the request was only partly honoured, so callers waiting on the callback wait forever. Removing the feature is the stated purpose, but accepting its parameters without any signal is an avoidable cost on top of that removal.

Verification: Trigger: an existing integration keeps sending target_format to POST /documents. After the diff, upload_doc in backend/app/api/routes/documents/document.py declares only session, current_user and src: UploadFile = File(...). FastAPI does not reject undeclared multipart fields. Now there is no job and no error. Callback-driven callers are not covered.

@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Ayush8923 Ayush8923 changed the title chore(documents): Remove document transformation module chore(documents): Remove Unused document transformation module Dec 4, 2026
@Ayush8923 Ayush8923 changed the title chore(documents): Remove Unused document transformation module chore(doc-transformation): Remove Unused document transformation module Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

OpenAPI changes   🔴 12 breaking changes

Caution

Downstream consumers may need an update before merging.

Breaking changes  ·  12
Method Path Change
🔴 GET /api/v1/documents/transformation API path removed without deprecation
🔴 GET /api/v1/documents/transformation/{job_id} API path removed without deprecation
🔴 GET /api/v1/openai-conversation API path removed without deprecation
🔴 GET /api/v1/openai-conversation/ancestor/{ancestor_response_id} API path removed without deprecation
🔴 GET /api/v1/openai-conversation/response/{response_id} API path removed without deprecation
🔴 DELETE /api/v1/openai-conversation/{conversation_id} API path removed without deprecation
🔴 GET /api/v1/openai-conversation/{conversation_id} API path removed without deprecation
🔴 POST /api/v1/responses API path removed without deprecation
🔴 POST /api/v1/responses/sync API path removed without deprecation
🔴 POST /api/v1/documents removed the request property callback_url
🔴 POST /api/v1/documents removed the request property target_format
🔴 POST /api/v1/documents removed the request property transformer
Full changelog  ·  30
Method Path Change
🔴 GET /api/v1/documents/transformation API path removed without deprecation
🔴 GET /api/v1/documents/transformation/{job_id} API path removed without deprecation
🔴 GET /api/v1/openai-conversation API path removed without deprecation
🔴 GET /api/v1/openai-conversation/ancestor/{ancestor_response_id} API path removed without deprecation
🔴 GET /api/v1/openai-conversation/response/{response_id} API path removed without deprecation
🔴 DELETE /api/v1/openai-conversation/{conversation_id} API path removed without deprecation
🔴 GET /api/v1/openai-conversation/{conversation_id} API path removed without deprecation
🔴 POST /api/v1/responses API path removed without deprecation
🔴 POST /api/v1/responses/sync API path removed without deprecation
🔴 POST /api/v1/documents removed the request property callback_url
🔴 POST /api/v1/documents removed the request property target_format
🔴 POST /api/v1/documents removed the request property transformer
🟢 — — removed the schema APIResponse_CallbackResponse_
🟢 — — removed the schema APIResponse_DocTransformationJobPublic_-Input
🟢 — — removed the schema APIResponse_DocTransformationJobPublic_-Output
🟢 — — removed the schema APIResponse_DocTransformationJobsPublic_
🟢 — — removed the schema APIResponse_OpenAIConversationPublic_
🟢 — — removed the schema APIResponse_ResponseJobStatus_
🟢 — — removed the schema APIResponse_list_OpenAIConversationPublic__
🟢 — — removed the schema CallbackResponse
🟢 — — removed the schema Diagnostics
🟢 — — removed the schema DocTransformationJobPublic
🟢 — — removed the schema DocTransformationJobsPublic
🟢 — — removed the schema OpenAIConversationPublic
🟢 — — removed the schema ResponseJobStatus
🟢 — — removed the schema ResponsesAPIRequest
🟢 — — removed the schema ResponsesSyncAPIRequest
🟢 — — removed the schema TransformationJobInfo
🟢 — — removed the schema TransformationStatus
🟢 POST /api/v1/documents removed the optional property data/anyOf[subschema #1: DocumentUploadResponse]/transformation_job from the response with the 200 status

main ↔ d407881c · generated by oasdiff

@Ayush8923 Ayush8923 added the breaking-change-approved Reviewer-acknowledged API breaking change label Dec 5, 2026
@Ayush8923
Ayush8923 requested review from AkhileshNegi, Prajna1999, kartpop and vprashrex and removed request for kartpop December 5, 2026 16:03

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change-approved Reviewer-acknowledged API breaking change ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleanup: Remove unused backend modules

1 participant