feat(textract): migrate to AWS SDK, add AnalyzeExpense and AnalyzeID#5456
feat(textract): migrate to AWS SDK, add AnalyzeExpense and AnalyzeID#5456waleedlatif1 wants to merge 6 commits into
Conversation
- Replace hand-rolled AWS SigV4 signing with @aws-sdk/client-textract, matching sibling AWS integrations (secrets_manager, s3, sts) - Add Analyze Expense operation (invoice/receipt structured extraction) via AnalyzeExpense/StartExpenseAnalysis+GetExpenseAnalysis - Add Analyze Identity Document operation (AnalyzeID) with optional back-of-ID page - Add an operation selector to the textract_v2 block; defaults to the existing Analyze Document behavior for backward compatibility - Add tests for tool body/response mapping and route-level AWS response normalization
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Adds two API surfaces and tools: Analyze Expense (sync Extends Reviewed by Cursor Bugbot for commit 55cb4eb. Configure here. |
- textract_analyze_expense/textract_analyze_id now fall back to filePath/filePathBack when the document input is a URL string rather than an uploaded file object, so advanced "File reference" URL inputs actually reach the API (Cursor Bugbot) - mapTextractSdkError defaults to 500 (not 400) when the AWS SDK error has no HTTP status, since that implies a server-side/network failure rather than a bad request (Greptile)
|
@cursor review |
- Front-document fields (fileUpload/fileReference) are shared across all 3 operations; gate them with a values-aware condition so switching to Analyze Identity Document keeps them visible even if a stale processingMode='async' is left over from a previous operation - S3 URI field now also requires operation !== 'analyze_id', since that operation never supports S3 input
|
@cursor review |
pollTextractJob's merge callbacks spread only the latest page, dropping any field (DocumentMetadata, model version) the first page had but a follow-up NextToken page omits. Merge accumulated first so later pages only override fields they actually return.
|
@cursor review |
…ch failures fetchDocumentBytes hardcoded 400 for any non-OK response from a document URL, masking transient 5xx failures from the document host as client errors and blocking tool-execution retries. Use the actual response status instead.
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit dd92247. Configure here.
|
@cursor review |
Summary
@aws-sdk/client-textractpackage, matching how sibling AWS integrations (Secrets Manager, S3, STS) already call AWSAnalyzeExpense(sync) /StartExpenseAnalysis+GetExpenseAnalysis(async, S3)AnalyzeID) for driver's licenses/passports, with an optional back-of-ID pageoperationdropdown to thetextract_v2block; defaults to the existing Analyze Document behavior so already-saved workflows are unaffectedtools/textract/types.tsType of Change
Testing
bun run type-check,bun run lint, andbun run check:api-validationall passChecklist