Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

This change fixes a 403 Forbidden error when using LiveGenerativeModel with API keys restricted to Android applications. The WebSocket handshake was missing the required X-Android-Package and X-Android-Cert headers. This patch ensures these headers are generated and applied during the WebSocket session establishment.


PR created automatically by Jules for task 17608199821067667969 started by @ryanwilson

…eaders

- Located the `getWebSocketSession` function in `APIController.kt`.
- Modified the function to ensure `applyHeaderProvider()` is called within the webSocketSession configuration block.
- Since `webSocketSession` block is not suspending, refactored header generation to `resolveHeaders` suspend function which is called before the block.
- Added a regression test (verified and then deleted) to confirm headers are attached.
- Verified that headers are correctly attached.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

📝 PRs merging into main branch

Our main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released.

@google-oss-bot
Copy link
Contributor

1 Warning
⚠️ Did you forget to add a changelog entry? (Add the 'no-changelog' label to the PR to silence this warning.)

Generated by 🚫 Danger

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jan 5, 2026

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jan 5, 2026

Size Report 1

Affected Products

  • firebase-ai

    TypeBase (c8ada3c)Merge (9baf160)Diff
    aar1.12 MB1.12 MB+2.73 kB (+0.2%)
    apk (aggressive)1.71 MB1.72 MB+980 B (+0.1%)
    apk (release)11.0 MB11.0 MB+1.71 kB (+0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/xg6mDlOcuo.html

…eaders

- Located the `getWebSocketSession` function in `APIController.kt`.
- Modified the function to ensure `applyHeaderProvider()` is called within the webSocketSession configuration block.
- Refactored header generation to `resolveHeaders` suspend function which is called before the block to handle Ktor's non-suspending configuration block.
- Applied resolved headers manually inside the block to ensure `X-Android-Package` and `X-Android-Cert` are present.
- Verified that headers are correctly attached with a test.
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.

1 participant