Skip to content

fix(provider): forward metadata options to cloudflare-ai-gateway provider#15619

Merged
thdxr merged 2 commits intoanomalyco:devfrom
ryanskidmore:fix/cloudflare-ai-gateway-metadata
Mar 3, 2026
Merged

fix(provider): forward metadata options to cloudflare-ai-gateway provider#15619
thdxr merged 2 commits intoanomalyco:devfrom
ryanskidmore:fix/cloudflare-ai-gateway-metadata

Conversation

@ryanskidmore
Copy link
Contributor

@ryanskidmore ryanskidmore commented Mar 1, 2026

Issue for this PR

Closes #15621

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The cloudflare-ai-gateway custom loader calls createAiGateway() without forwarding options.metadata from the provider config. This was introduced in PR #12014 when switching to the ai-gateway-provider package.

The fix reads metadata, cacheTtl, cacheKey, skipCache, and collectLog from input.options and forwards them to createAiGateway() when present. It also supports the legacy cf-aig-metadata header (JSON string) as a fallback for existing users who set metadata that way.

The createAiGateway() function already accepts options?: AiGatewayOptions — we just weren't passing them through.

How did you verify your code works?

  • 2 new tests added to test/provider/provider.test.ts — both verify metadata and options forwarding
  • Full test suite passes (70/70) via bun test test/provider/provider.test.ts
  • Typecheck passes via bun turbo typecheck
  • Verified against CF AI Gateway metadata docs

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 1, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

- Replace destructuring with dot notation per style guide
- Use iife() helper instead of raw IIFE pattern
- Remove excessive comments, reduce variable count
- Add 2 tests for cloudflare-ai-gateway provider loading and config metadata

Fixes anomalyco#15621
@github-actions github-actions bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Mar 1, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Copy link
Contributor

@elithrar elithrar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@thdxr thdxr merged commit 96d6fb7 into anomalyco:dev Mar 3, 2026
13 checks passed
Grappeggia pushed a commit to teamslop/slopcode that referenced this pull request Mar 4, 2026
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.

cloudflare-ai-gateway provider does not forward metadata options to createAiGateway()

3 participants