mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
* fix(apigatewayv2): resolve HTTP API region across regions like REST APIs do Unsigned requests (and requests carrying a non-SigV4 Authorization header, e.g. a Cognito bearer JWT) resolve to RegionResolver's configured default region rather than a region the caller specified. For v1 REST APIs, resolveRestApiRegion already falls back to scanning all regions for the apiId when that happens. HTTP API (v2) dispatch had no equivalent, so any HTTP API deployed outside the default region returned 404 "Invalid API id specified" for every unsigned or bearer-token-authenticated request - which is effectively every request a browser, curl, or non-SigV4 client sends. Adds ApiGatewayV2Service#resolveHttpApiRegion, mirroring ApiGatewayService#resolveRestApiRegion exactly (same region::apiId key shape), and RegionResolver#isRegionUnresolved to give dispatch() a single correct signal for "region resolution silently fell back to the default" that covers both the blank-header and non-SigV4-header cases the previous blank-check missed. * test(apigateway): cover HTTP API cross-region resolution and non-SigV4 fallback Adds unit coverage for the dispatch() region-resolution fix: - An unsigned request for a v2 HTTP API deployed outside the default region must fall back to resolveHttpApiRegion and find it there. - A correctly-resolved (signed) request must not pay for the fallback scan. - A non-SigV4 Authorization header (e.g. a Cognito bearer JWT) on a v1 REST API must also trigger the region scan, not just a blank/missing header — using a real RegionResolver rather than a mock so the test exercises the actual header-parsing logic in isRegionUnresolved. Verified each test fails when the corresponding fix is reverted: the v2 test and the bearer-JWT test both fail (2 of 12) when dispatch()'s region-fallback logic is rolled back to the pre-fix version, confirming they aren't vacuously passing. * chore: trigger CI * refactor(apigateway): drop duplicate RegionResolver.isRegionUnresolved #2169 (merged) added resolveRegionFromAuthOrNull, the same predicate as isRegionUnresolved added here. Collapse onto the former per hectorvent's review note on #2169 rather than let both live in core/common. * test(apigateway): update mocks for merged v1-first dispatch flow Finish resolving the PR #2149 merge conflict — the test file's edits for the merged dispatch() ordering weren't included in the merge commit. * test(apigateway): note that v2 region tests pin #2054, not this PR Per review feedback on #2149: unsignedRequestFindsV2ApiDeployedOutsideDefaultRegion and signedV2RequestDoesNotConsultRegionFallback exercise v2 cross-region dispatch behavior that landed independently in #2054, not the v1 Authorization-header fix this PR makes. Kept as the only controller-level coverage of that behavior, with a comment so they aren't read as regression guards for this change.