Skip to content

fix: force download on agentic traffic export URLs | LLMO-4888#2527

Open
calvarezg wants to merge 5 commits into
mainfrom
feat-LLMO-4888-agentic-traffic-export
Open

fix: force download on agentic traffic export URLs | LLMO-4888#2527
calvarezg wants to merge 5 commits into
mainfrom
feat-LLMO-4888-agentic-traffic-export

Conversation

@calvarezg

Copy link
Copy Markdown
Contributor

Please ensure your pull request adheres to the following guidelines:

  • Related issue linked below (LLMO-4888)
  • Fix commit includes the issue reference for release notes

If the PR is changing the API specification:

  • N/A — no API contract change; presigned URL generation is internal.

If the PR is changing the API implementation or an entity exposed through the API:

  • N/A — ResponseContentDisposition / ResponseContentType are Response* override parameters baked into the presigned URL query string. The stored S3 object is unchanged.

Related Issues

LLMO-4888: https://jira.corp.adobe.com/browse/LLMO-4888

Chrome opens agentic traffic export CSVs inline as text instead of downloading them. Firefox and Safari handle it correctly. Root cause: presigned S3 URLs for spacecat-prod-reports (no CORS) lacked Content-Disposition: attachment, so Chrome renders the response inline.

Adds ResponseContentDisposition: 'attachment; filename="urls.csv"' and ResponseContentType: 'text/csv; charset=utf-8' to GetObjectCommand in buildExportReadyResponse. For multi-part exports the filename becomes urls_part1.csv, urls_part2.csv, etc. No import changes needed — these are first-class GetObjectCommand options.

Thanks for contributing!

…ed URLs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@calvarezg calvarezg self-assigned this Jun 1, 2026
@calvarezg

Copy link
Copy Markdown
Contributor Author

Self-review (fresh-context)

[Correctness] In the fast-path (metadata.files), safeFiles is the filtered metadata.files array with no sort applied, so array index i may not match the intended part number. listExportCsvObjects sorts by part number before returning, but validateFilesAgainstPrefix only filters — it does not sort. If the worker writes metadata.files in a different order, urls_part1.csv in Content-Disposition could be attached to the wrong S3 key. src/controllers/llmo/llmo-agentic-traffic.js:772. Fix: sort safeFiles by part number (same comparator used in listExportCsvObjects) before passing to buildExportReadyResponse.

[Test gap] No test asserts that GetObjectCommand is constructed with ResponseContentDisposition and ResponseContentType. The existing multi-part test at line 1687 only checks downloadUrls values; a future refactor could silently drop the response-override params. Consider adding a check on ctx.s3.GetObjectCommand call args (accessible via the constructor stub) that the new fields are present and correctly valued for both the single-file and multi-part cases.

@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/controllers/llmo/llmo-agentic-traffic.js 89.47% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

calvarezg and others added 2 commits June 1, 2026 11:28
…st path (#4591073564)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ests (#4591073564)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

This PR will trigger a patch release when merged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.

1 participant