Skip to content

test(translation): cover file attachments routed to Anthropic - #862

Merged
dagardner-nv merged 2 commits into
NVIDIA-NeMo:mainfrom
dagardner-nv:test/translation-file-attachments
Sep 28, 2026
Merged

dagardner-nv merged 2 commits into
NVIDIA-NeMo:mainfrom
dagardner-nv:test/translation-file-attachments

Conversation

@dagardner-nv

@dagardner-nv dagardner-nv commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What

  • Improved test coverage for the encode_anthropic_file method in crates/switchyard-translation/src/codecs/anthropic/buffered.rs

Why

These request translation paths lacked tests. The new cases protect the file content and error behavior when Switchyard routes OpenAI requests to Anthropic.

Notes for reviewers

Start with crates/switchyard-translation/tests/request_translation.rs. This PR changes tests only.

Validation: cargo fmt --all --check, cargo clippy --workspace --all-targets --offline -- -D warnings, and cargo test -p switchyard-translation --offline passed.

Summary by CodeRabbit

  • Tests
    • Expanded coverage for translating file and media inputs, including preserving document titles when processing URL-based files.
    • Added checks for clear errors when file data is missing or invalid, contains non-text bytes, or uses an unsupported media format.

Signed-off-by: David Gardner <dagardner@nvidia.com>
…anslation-file-attachments

Signed-off-by: David Gardner <dagardner@nvidia.com>
@dagardner-nv dagardner-nv changed the title test(translation): cover file attachment conversions test(translation): cover file attachments routed to Anthropic Sep 28, 2026
@dagardner-nv
dagardner-nv marked this pull request as ready for review September 28, 2026 17:45
@dagardner-nv
dagardner-nv requested a review from a team as a code owner September 28, 2026 17:45
@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: NVIDIA-NeMo/Switchyard/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a35cde7c-2073-4b40-a1d3-3f1150068318

📥 Commits

Reviewing files that changed from the base of the PR and between 87bec96 and 9b98908.

📒 Files selected for processing (1)
  • crates/switchyard-translation/tests/request_translation.rs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Walkthrough

The request translation tests add coverage for Responses URL-file titles and for Chat and Responses file inputs translated to Anthropic. The new cases assert errors for invalid text data, image data supplied as a document, and files without a supported source.

Changes

Anthropic document translation tests

Layer / File(s) Summary
Document translation cases
crates/switchyard-translation/tests/request_translation.rs
Tests check the title on a translated URL file. They also check InvalidValue errors for malformed base64 and non-UTF-8 text, and LossyConversion errors for image data supplied as a document or a file without a supported source.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 9b989

The added attachment-translation tests protect the intended behavior, with no identified issue requiring a change before merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding translation tests for file attachments routed to Anthropic.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

A rabbit checks each file with care
A titled report hops into view
Bad text gets errors, clear and true
Image pages cannot pass as PDFs
No source? The tests catch that too
Then off the rabbit bounds anew

Comment @coderabbitai help to get the list of available commands.

@dagardner-nv
dagardner-nv merged commit a601a9a into NVIDIA-NeMo:main Sep 28, 2026
18 checks passed
@dagardner-nv
dagardner-nv deleted the test/translation-file-attachments branch September 28, 2026 18:07
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