Skip to content

Onboarding: Revert Google enum fix#1062

Open
Prajna1999 wants to merge 3 commits into
mainfrom
hotfix/google-aistudio-creds-revert-last-release-cherrypick
Open

Onboarding: Revert Google enum fix#1062
Prajna1999 wants to merge 3 commits into
mainfrom
hotfix/google-aistudio-creds-revert-last-release-cherrypick

Conversation

@Prajna1999

@Prajna1999 Prajna1999 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Issue #1060

Summary

  • Before: The google provider required project_id, location, sa_key, gcs_bucket, and sa_key was considered sensitive.
  • Now: The google provider requires only api_key, and all other fields have been dropped. Text completions for the google provider are now processed via the api-key Gemini client.
  • The guard rejecting text completions was removed.
  • Tests were updated to verify the new mapping behavior.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

This was a hotfix already deployed to prod. To be merged with main for staging and next steps.

Original PR description

Issue #1060

Summary

  • providers.py: google provider now requires only api_key — dropped project_id, location, sa_key, gcs_bucket from required fields, and sa_key from sensitive fields.
  • mappers.py: removed the guard that rejected text completions on the google provider; google + text now maps to a google-native config and executes via the api-key Gemini client (_execute_text).
  • test_mappers.py: updated the stale rejection test to assert google + text now maps to google-native.

Why it's safe

  • Credential change is strictly more permissive — no existing creds break; full-cred storage still works.
  • The wired GoogleAIProvider needs only api_key; the Vertex provider (google_ai.py) isn't in the registry and has settings fallbacks for every dropped field.
  • Only one test depended on the old behavior; now fixed.

Reviewer confirm

  • ⚠️ sa_key removed from sensitive fields → any existing stored sa_key is now returned unmasked in GET /credentials. No test covers this. Intended?
  • Suite not run live — test DB schema is stale locally.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

This was a hotfix already deployed to prod. To be merged with main for staging and next steps.

@Prajna1999 Prajna1999 self-assigned this Jul 22, 2026
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Google provider configuration now masks only api_key, while Google text completions are accepted by native routing and mapped through the Google parameter mapper. Tests now verify the successful google-native result and preserved model parameter.

Changes

Google provider behavior

Layer / File(s) Summary
Google credential masking
backend/app/core/providers.py
Google provider sensitive fields now contain only api_key; sa_key is no longer masked.
Google text completion routing
backend/app/services/llm/mappers.py, backend/app/tests/services/llm/test_mappers.py
Google text completions no longer raise a routing error and are mapped to google-native, with tests verifying the mapped model parameter.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: akhileshnegi, vprashrex

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes revert Google onboarding away from GCP credential requirements and update routing/tests accordingly, matching issue #1060.
Out of Scope Changes check ✅ Passed The diff stays focused on Google credential routing, masking, and tests with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is relevant to the Google credential/routing revert, though it is a bit terse.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/google-aistudio-creds-revert-last-release-cherrypick

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot changed the title Hotfix/google aistudio creds revert last release cherrypick fix(google): Update google provider fields Jul 22, 2026
@github-actions

Copy link
Copy Markdown

OpenAPI changes   ⚪ No API surface changes

Note

This PR does not modify the API contract.

main816980c8 · generated by oasdiff

@Prajna1999 Prajna1999 changed the title fix(google): Update google provider fields Onboarding: Revert Google enum fix Jul 23, 2026
@Prajna1999 Prajna1999 added bug Something isn't working ready-for-review labels Jul 23, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
backend/app/tests/services/llm/test_mappers.py (1)

901-906: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert that valid routing emits no warnings.

The test verifies the provider and model but ignores warnings; a mapper regression could therefore pass while silently dropping parameters.

Proposed assertion
        assert native_config.provider == "google-native"
        assert native_config.params["model"] == "gemini-2.5-pro"
+       assert warnings == []
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/tests/services/llm/test_mappers.py` around lines 901 - 906,
Update the test around transform_kaapi_config_to_native to assert that warnings
is empty for this valid routing configuration, while preserving the existing
provider and model assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/app/core/providers.py`:
- Line 56: Update the provider configuration’s sensitive_fields list to retain
sa_key alongside api_key, ensuring mask_credential_fields() continues masking
legacy Google service-account credentials, including private_key, in API-facing
responses.

In `@backend/app/tests/services/llm/test_mappers.py`:
- Line 892: Update the test_text_completion_maps_via_google_mapper method
signature to include the missing None return annotation, while retaining the
existing db: Session parameter annotation.

---

Nitpick comments:
In `@backend/app/tests/services/llm/test_mappers.py`:
- Around line 901-906: Update the test around transform_kaapi_config_to_native
to assert that warnings is empty for this valid routing configuration, while
preserving the existing provider and model assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3da82390-f6c8-4923-9f49-a948e4c10713

📥 Commits

Reviewing files that changed from the base of the PR and between ff46094 and a7d7e70.

📒 Files selected for processing (3)
  • backend/app/core/providers.py
  • backend/app/services/llm/mappers.py
  • backend/app/tests/services/llm/test_mappers.py
💤 Files with no reviewable changes (1)
  • backend/app/services/llm/mappers.py

"gcs_bucket",
],
sensitive_fields=["api_key", "sa_key"],
sensitive_fields=["api_key"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Keep sa_key masked until legacy Vertex credentials are removed.

mask_credential_fields() derives its mask list from this configuration. With only api_key listed, a stored Google sa_key object—including private_key, as shown in backend/app/tests/crud/test_credentials.py:89-132—passes through unchanged and can be exposed by API-facing credential responses.

Retain sa_key as sensitive, or explicitly strip legacy service-account data before returning credentials.

Proposed fix
-        sensitive_fields=["api_key"],
+        sensitive_fields=["api_key", "sa_key"],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sensitive_fields=["api_key"],
sensitive_fields=["api_key", "sa_key"],
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/core/providers.py` at line 56, Update the provider
configuration’s sensitive_fields list to retain sa_key alongside api_key,
ensuring mask_credential_fields() continues masking legacy Google
service-account credentials, including private_key, in API-facing responses.

def test_text_completion_is_rejected(self, db: Session):
"""``google`` is audio-only (Vertex STT/TTS) — text completions
must be routed through ``google-aistudio``."""
def test_text_completion_maps_via_google_mapper(self, db: Session):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the missing -> None return annotation.

As per coding guidelines: **/*.py: Use type hints on every function parameter and return value.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/tests/services/llm/test_mappers.py` at line 892, Update the
test_text_completion_maps_via_google_mapper method signature to include the
missing None return annotation, while retaining the existing db: Session
parameter annotation.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant