Repository navigation
fix(auth): gate invalid-key check on isRequireApiKeyEnabled for embeddings and web-fetch (#7785) - #7810
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
a4c8745 to
0b92f2f
Compare
|
Thanks for tracking down #7785 and matching it to the /v1/combos pattern — the 2-line gate in both route.ts files is exactly the right fix, and the new test file is solid coverage for the intended behavior. One thing to fix before merge: CI's Unit Tests (8/8) job is currently red because of this change. Also: this PR targets (The other two red checks — Quality Gates Extended / Quality Ratchet — are unrelated pre-existing baseline drift on |
…dings and web-fetch (cheaper-inference#7785) When REQUIRE_API_KEY=false, /v1/embeddings and /v1/web/fetch still returned 401 for invalid presented keys while all other client APIs allowed anonymous access. The route-local invalid-key check was not gated on isRequireApiKeyEnabled(), unlike the /v1/combos pattern. Gate the invalid-key check on isRequireApiKeyEnabled() in both route files so anonymous access works consistently across all client APIs. Refs: cheaper-inference#7785
78ec5de to
ffaacab
Compare
…ubtest The "should return 401 when an invalid API key is provided" test now correctly sets REQUIRE_API_KEY="true" so the route-level gated check is exercised. Before, the test asserted 401 when REQUIRE_API_KEY was not set, which after cheaper-inference#7785 fix now returns 400 (model validation fails) instead of 401.
…ite (cheaper-inference#7785) Per cheaper-inference#7785's acceptance criteria, the pre-existing embeddings regression test must assert BOTH enforcement states, not just the enforced-401 case. Add the missing REQUIRE_API_KEY=false + invalid-key subtest alongside the already-fixed REQUIRE_API_KEY=true + invalid-key subtest, matching the coverage already present in the dedicated auth-policy-embeddings-webfetch-7785.test.ts suite. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
|
Validated in local merge-train on tomni-proxmox-113 @ 19bcf534352e24cdd2448cdfdfd64d5bd9695c74 (FAST gates green: static + changed tests + vitest) |
adbcd2c
into
cheaper-inference:release/v3.8.49
…dings and web-fetch (cheaper-inference#7785) (cheaper-inference#7810) * fix(auth): gate invalid-key check on isRequireApiKeyEnabled for embeddings and web-fetch (cheaper-inference#7785) When REQUIRE_API_KEY=false, /v1/embeddings and /v1/web/fetch still returned 401 for invalid presented keys while all other client APIs allowed anonymous access. The route-local invalid-key check was not gated on isRequireApiKeyEnabled(), unlike the /v1/combos pattern. Gate the invalid-key check on isRequireApiKeyEnabled() in both route files so anonymous access works consistently across all client APIs. Refs: cheaper-inference#7785 * fix(tests): set REQUIRE_API_KEY=true in embeddings-auth invalid-key subtest The "should return 401 when an invalid API key is provided" test now correctly sets REQUIRE_API_KEY="true" so the route-level gated check is exercised. Before, the test asserted 401 when REQUIRE_API_KEY was not set, which after cheaper-inference#7785 fix now returns 400 (model validation fails) instead of 401. * test(auth): assert anonymous-passthrough in embeddings-auth legacy suite (cheaper-inference#7785) Per cheaper-inference#7785's acceptance criteria, the pre-existing embeddings regression test must assert BOTH enforcement states, not just the enforced-401 case. Add the missing REQUIRE_API_KEY=false + invalid-key subtest alongside the already-fixed REQUIRE_API_KEY=true + invalid-key subtest, matching the coverage already present in the dedicated auth-policy-embeddings-webfetch-7785.test.ts suite. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com> Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
…dings and web-fetch (cheaper-inference#7785) (cheaper-inference#7810) * fix(auth): gate invalid-key check on isRequireApiKeyEnabled for embeddings and web-fetch (cheaper-inference#7785) When REQUIRE_API_KEY=false, /v1/embeddings and /v1/web/fetch still returned 401 for invalid presented keys while all other client APIs allowed anonymous access. The route-local invalid-key check was not gated on isRequireApiKeyEnabled(), unlike the /v1/combos pattern. Gate the invalid-key check on isRequireApiKeyEnabled() in both route files so anonymous access works consistently across all client APIs. Refs: cheaper-inference#7785 * fix(tests): set REQUIRE_API_KEY=true in embeddings-auth invalid-key subtest The "should return 401 when an invalid API key is provided" test now correctly sets REQUIRE_API_KEY="true" so the route-level gated check is exercised. Before, the test asserted 401 when REQUIRE_API_KEY was not set, which after cheaper-inference#7785 fix now returns 400 (model validation fails) instead of 401. * test(auth): assert anonymous-passthrough in embeddings-auth legacy suite (cheaper-inference#7785) Per cheaper-inference#7785's acceptance criteria, the pre-existing embeddings regression test must assert BOTH enforcement states, not just the enforced-401 case. Add the missing REQUIRE_API_KEY=false + invalid-key subtest alongside the already-fixed REQUIRE_API_KEY=true + invalid-key subtest, matching the coverage already present in the dedicated auth-policy-embeddings-webfetch-7785.test.ts suite. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com> Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Problem
When
REQUIRE_API_KEY=false,/api/v1/embeddingsand/api/v1/web/fetchstill return401for invalid presented keys while all other client APIs allow anonymous access. This is an inconsistency in the optional API-key policy.Closes #7785
Root cause
Both routes checked
isRequireApiKeyEnabled()for the missing-key case but NOT for the invalid-key case:The
/v1/combosroute already handles this correctly — whenREQUIRE_API_KEY=falseit falls through to anonymous access regardless of whether a (possibly invalid) key was presented.Fix
Gate the invalid-key check on
isRequireApiKeyEnabled()in both route files:This matches the
/v1/combospattern and makes anonymous access consistent across all client APIs.Changes
src/app/api/v1/embeddings/route.ts— gate invalid-key check onisRequireApiKeyEnabled()src/app/api/v1/web/fetch/route.ts— same gatetests/unit/auth-policy-embeddings-webfetch-7785.test.ts— 4 tests covering both routes × both flag statesTesting
Existing embeddings test (
embeddings-route-apikeymeta-6929.test.ts) still passes — no regression.