Skip to content

fix(llm): Remove duplicate property ordering - #1186

Closed
vprashrex wants to merge 1 commit into
mainfrom
fix/gemini-duplicate-property-ordering
Closed

vprashrex wants to merge 1 commit into
mainfrom
fix/gemini-duplicate-property-ordering

Conversation

@vprashrex

@vprashrex vprashrex commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Closes #PLEASE_TYPE_ISSUE_NUMBER

Summary

  • Before: The Vertex rejected each batch assessment row due to duplicate property_ordering fields in the schema.
  • Now: The SDK's snake_case property_ordering is removed before adding the required camelCase key, preventing duplication.
  • Required modifications in both services/assessment/mappers.py and services/llm/mappers.py.

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

Please add here if any other information is required for the reviewer.

Original PR description

Problem

Every google-gcp batch assessment that uses a json_output_schema fails: Vertex rejects each row with

Unable to submit request because property_ordering contains duplicate field Idea_Feedback

(observed on prod assessment 432ef1d9, batch job 1096 — all 998 rows errored).

Root cause

_convert_json_schema_to_google() normalizes the schema through genai_transformers.t_schema() and dumps it with model_dump(mode="json") — without by_alias, so the SDK emits snake_case property_ordering. The guard below only checks camelCase:

if "properties" in google_schema and "propertyOrdering" not in google_schema:

so the mapper adds a second, camelCase ordering. Vertex merges both keys into one ordering where every field appears twice, and rejects the request.

Fix

Pop the SDK's snake_case property_ordering before adding the required-order camelCase key, in both copies of the converter (services/assessment/mappers.py, services/llm/mappers.py).

Verification

  • Reproduced locally: current mapper output contains both propertyOrdering and property_ordering for the failing schema — byte-identical to the request captured in the batch-1096 predictions JSONL.
  • Ran a live Vertex batch job (gemini-2.5-flash-lite) with the fixed schema: JOB_STATE_SUCCEEDED, all rows returned valid structured output matching the schema.

🤖 Generated with Claude Code

…e schema

genai_transformers.t_schema().model_dump() emits snake_case property_ordering
(no by_alias), and the mapper's guard only checks camelCase propertyOrdering
before adding its own required-order list. The request therefore carries both
keys; Vertex merges them into one ordering with every field duplicated and
rejects the request with 'property_ordering contains duplicate field ...',
failing every google-gcp batch row that uses a json_output_schema.

Pop the snake_case key so exactly one ordering (required-field order) is sent.
Verified against a live Vertex batch job: previously-failing schema now returns
valid structured output.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ready-for-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 0fdb6516-a43d-454a-b236-50982fcb0701

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 fix(llm): Drop SDK's snake_case property_ordering from Gemini response schema fix(llm): Remove duplicate property ordering Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

OpenAPI changes   ⚪ No API surface changes

Note

This PR does not modify the API contract.

main ↔ fd42999d · generated by oasdiff

@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/app/services/llm/mappers.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@vprashrex vprashrex closed this Sep 7, 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.

1 participant