Repository navigation
test: port the upstream Anthropic AWS tests - #319
Merged
Merged
Conversation
Ports @ai-sdk/anthropic-aws 2.0.63 src/anthropic-aws-fetch.test.ts, anthropic-aws-provider.test.ts and region-validation.test.ts into src/anthropic_aws/tests/, one Rust file per upstream file: 46 of the 53 cases, each with its upstream marker. The other 7 are listed in layout.toml. Expectations are upstream's; the harness differs where Rust has no counterpart (real SigV4 signing instead of the mocked aws4fetch, the pinned user-agent version). The boundary check skips tests/ directories for the Anthropic family too, since upstream's expected header value "wrkspc_from_env" is test data. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
This was referenced Oct 20, 2026
…est/port-the-upstream-anthropic-aws-tests Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
cunninghamcard-bit
marked this pull request as ready for review
October 24, 2026 11:02
6 of 12 tasks
eric8810
approved these changes
Oct 25, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Anthropic AWS test port:46 tests + 7 exclusions = 53,fixtures/断言精确,无生产变化。建议收窄 tests/ 的 boundary exclusion,并补一个 SigV4 list_models 断言。Approve。
… list_models
The boundary rule for builder-era Anthropic state scanned no tests/
directory at all; it now scans them and skips only the upstream
workspace-id value "wrkspc_from_env" in src/anthropic_aws/tests/provider.rs.
A new aimux-own test checks that list_models with SigV4 auth sends one
signed GET of {base_url}/models without an API key.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
Contributor
Author
Generated by Claude Code |
…efault-fetch-per-request' into test/port-the-upstream-anthropic-aws-tests
…t' into test/port-the-upstream-anthropic-aws-tests # Conflicts: # aimux-providers/layout.toml
…t' into test/port-the-upstream-anthropic-aws-tests # Conflicts: # aimux-providers/layout.toml
…t' into test/port-the-upstream-anthropic-aws-tests # Conflicts: # aimux-providers/layout.toml
…t' into test/port-the-upstream-anthropic-aws-tests # Conflicts: # aimux-providers/layout.toml
…t' into test/port-the-upstream-anthropic-aws-tests
eric8810
approved these changes
Oct 27, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Verified the post-approval commits on this head: only additive tests/docs or tightened boundary checks; no weakening or behavior regression. Re-approving the current head.
…t' into test/port-the-upstream-anthropic-aws-tests # Conflicts: # aimux-providers/layout.toml
…t' into test/port-the-upstream-anthropic-aws-tests # Conflicts: # aimux-providers/layout.toml
eric8810
changed the base branch from
fix/anthropic-aws-resolves-the-default-fetch-per-request
to
master
October 27, 2026 07:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
按 RFC-0045(#281)把
@ai-sdk/anthropic-aws@2.0.63的上游测试迁完,按厂商分批的第七个(Mistral #295、Cohere #296、DeepSeek #299、Groq #301、Hugging Face #303、xAI #312)。上游 3 个测试文件共 53 个用例:
tests/anthropic_aws_settings_test.rs等)测的是 aimux 自己的设置规则,和上游用例不一一对应,没有加标记。layout.toml的手写排除:registered:aimux 也给 GET 和无 body 的请求签名(对齐文档 §9.1 已知差距,list_models要用);创建模型时不读 region,缺 region 在第一次请求时报错(§5「不可失败的默认 provider 访问」、§3.3 Anthropic-AWS 行)。sub-feature:files()、skills(),AWS provider 没有(Provider 构造与配置:迁移后遗留缺口 #275)。ts-only:JS 对象 body 被JSON.stringify;用new调 provider 函数。迁移中发现 5 处行为差异,各自单独一个 fix PR,叠成一串,本 PR 叠在最后一个上:
anthropic-aws,上游是anthropic-aws.messages。http(s)的image/*和application/pdf。AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY时只给LoadSetting,上游给一段如何提供凭证的说明。AWS credential provider failed: …。fetch时在创建时就取定默认 transport,上游每次请求读globalThis.fetch。另有两处没有当作这个包的差异修,标记照留,在用例上写明:
NoSuchModel的文案。上游是No such embeddingModel: …,aimux-core 统一是no such model: …。这是 core 的差异,随 core 的测试迁移处理。这 2 个用例比对的是变体和model_type。call original fetch if init is undefined这个用例。它的请求是 GET,aimux 会签名(同上面的登记差异),所以只比对请求原样到达原 transport,不比对未签名的 headers。位置按新定的布局:新测试全放
src/anthropic_aws/tests/,一个上游测试文件对应一个 Rust 文件。一、体系概览:Anthropic AWS 的测试现在怎么跑(master
b91829af)上游
packages/anthropic-aws/src/对应:改动前 aimux 没有一个测试和这 53 个上游用例一一对应。
二、本 PR 的改动(细节)
1. 新测试目录(
anthropic_aws/mod.rs末尾#[cfg(test)] mod tests;)2.
aimux-providers/layout.toml(只有[anthropic_aws])harness 上的差别(期望值都没改):
aws4fetch和时钟,这里 SigV4 真签,authorization只比格式和 credential scope,x-amz-date只比格式和时间范围。ai-sdk-anthropic-aws/2.0.63(钉住的版本),不比上游 mock 的0.0.0-test testenv。Request和init两层合成一个FetchRequest。Uint8Array、ArrayBuffer都是 bytes。cache: 'no-cache'没有对应字段,不比。InvalidArgument只带 message,argument: 'region'改比变体、message 和 wire 上的AI_InvalidArgumentError。ApiCall,前面带failed to resolve AWS credentials:(见 fix: Anthropic AWS wraps credential provider failures #317 的说明)。Type of change
Checklist
cargo +1.99 fmt -p aimux-providers -- --checkpassescargo +1.99 clippy -p aimux-providers --lib --tests -- -D warningspassescargo +1.99 test -p aimux-providers:lib 181(其中 anthropic_aws 46),129 个测试二进制共 2405 个,全过1a532dc1):fmt、clippy、边界检查通过,cargo test -p aimux-providers --lib加anthropic_aws*测试程序共 2 个、198 个测试全过;anthropic_aws的 lib 测试 47 个(46 个上游 + 1 个 aimux 自己的 SigV4list_models测试)scripts/check_provider_boundaries.shpassesNotes for reviewers
src/test_support/mod.rs、aimux-providers/layout.toml,并改了边界脚本的同两行;这几处在各 PR 里内容相同,后合入的只需合并layout.toml的厂商表。本 PR 还改了规则 6:原来对整个 tests/ 目录加--exclude-dir=tests,评审后收窄成只滤掉"wrkspc_from_env"这一个上游测试值(它含from_env字样,但只是数据,不是调用)。layout.toml的手写排除里。src/anthropic_aws/tests/fetch.rs末尾有 1 个不对应上游用例的测试list_models_with_sigv4_auth_sends_a_signed_get(评审后加):SigV4 鉴权下list_models只发一次GET {base_url}/models,请求带签名(authorization、x-amz-date、x-amz-security-token),不带 API key,响应解析成模型列表。files()、skills()的缺口挂在 Provider 构造与配置:迁移后遗留缺口 #275,行为差异挂在 Core 运行时:与 AI SDK 的剩余差距(对齐文档 §9.1 已知差距) #276。Generated by Claude Code