Skip to content

refactor(data-connector): remove redundant fields from StoredResponse - #574

Merged
slin1237 merged 4 commits into
mainfrom
keyang/db-redundant-field
Mar 2, 2026
Merged

slin1237 merged 4 commits into
mainfrom
keyang/db-redundant-field

Conversation

@key4ng

@key4ng key4ng commented Mar 2, 2026 •

Copy link
Copy Markdown
Member

Description

Problem

StoredResponse stores four fields that are redundant with raw_response: output (identical to raw_response["output"]), metadata and
instructions (write-only, never read back), and tool_calls (dead code, never populated).

Solution

Remove all four fields from the struct, schema, storage backends, and read/write paths. Add v3 database migrations to drop the columns. Read paths
now access output via raw_response.get("output").

Changes

  • data_connector/src/core.rs: Remove 4 fields from StoredResponse, update build_context() to read from raw_response
  • data_connector/src/common.rs: Remove columns from RESPONSE_COLUMNS, delete parse_tool_calls() and parse_metadata()
  • data_connector/src/schema.rs: Remove columns from core_columns_for("responses")
  • data_connector/src/postgres.rs: Remove from DDL, build_response_from_row, store_response
  • data_connector/src/oracle.rs: Same
  • data_connector/src/redis.rs: Same
  • data_connector/src/postgres_migrations.rs: Add v3 migration to drop 4 columns
  • data_connector/src/oracle_migrations.rs: Add v3 migration to drop 4 columns
  • model_gateway/src/routers/persistence_utils.rs: Remove redundant field assignments in write path
  • model_gateway/src/routers/openai/router.rs: Read output from raw_response instead of stored.output
  • model_gateway/src/routers/grpc/{regular,harmony}/responses/common.rs: Same

Test Plan

Checklist
  • cargo +nightly fmt passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • (Optional) Documentation updated

Summary by CodeRabbit

  • Refactor

    • Response storage now consolidates content into a single raw payload; former top-level fields (instructions, output, tool calls, metadata) are no longer separate and are accessed via the raw payload.
  • Chores

    • Added migrations to drop deprecated response columns and updated persistence and tests to the new raw-payload format.

@coderabbitai

coderabbitai Bot commented Mar 2, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 410a3c1 and 305fcec.

📒 Files selected for processing (3)
  • data_connector/src/oracle_migrations.rs
  • data_connector/src/postgres_migrations.rs
  • model_gateway/tests/routing/test_openai_routing.rs

📝 Walkthrough

Walkthrough

Removed dedicated response fields (instructions, output, tool_calls, metadata) from the model and storage schema; their content is now stored and read via raw_response JSON. Updated storage backends, migrations (v3), routers, persistence logic, and tests to use raw_response and drop the corresponding DB columns.

Changes

Cohort / File(s) Summary
Core model & schema
data_connector/src/common.rs, data_connector/src/core.rs, data_connector/src/schema.rs
Removed parse_tool_calls/parse_metadata; dropped "instructions", "output", "tool_calls", "metadata" from RESPONSE_COLUMNS; StoredResponse no longer exposes those fields; logic now sources output/related data from raw_response.
Storage backends
data_connector/src/oracle.rs, data_connector/src/postgres.rs, data_connector/src/redis.rs
Removed read/write/parse/serialize handling for the four fields; updated DDL/select/insert logic to exclude those columns and rely on raw_response.
Migrations
data_connector/src/oracle_migrations.rs, data_connector/src/postgres_migrations.rs
Added migration v3 to drop OUTPUT, METADATA, INSTRUCTIONS, TOOL_CALLS (idempotent per-column drops, skipping when mapped/extra); tests added/updated to validate drop/skip logic; migration arrays extended to include v3.
In-memory / hooked & tests
data_connector/src/memory.rs, data_connector/src/hooked.rs, data_connector tests
Replaced output usage with raw_response across in-memory stores and tests; fixtures now embed {"output": [...]} inside raw_response.
Gateway / routers / persistence
model_gateway/src/routers/..., model_gateway/src/routers/grpc/.../responses/common.rs, model_gateway/src/routers/openai/router.rs, model_gateway/src/routers/persistence_utils.rs
Changed history/loading and persist logic to read/write output items from stored.raw_response.get("output") instead of stored.output; removed assignments of removed fields when persisting.
Gateway tests & API tests
model_gateway/tests/api/api_endpoints_test.rs, model_gateway/tests/routing/test_openai_routing.rs
Updated tests/fixtures to set/read raw_response["output"]; removed direct assertions against removed top-level fields and adjusted expectations.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Gateway
    participant Storage
    participant DB

    Client->>Gateway: send response (includes output/instructions/etc.)
    Gateway->>Storage: build StoredResponse with raw_response = {"output": [...], ...}
    Storage->>DB: INSERT/UPDATE (no dedicated output/metadata columns)
    DB-->>Storage: OK
    Storage-->>Gateway: persisted id
    Gateway-->>Client: ack

    Client->>Gateway: request conversation history
    Gateway->>Storage: fetch StoredResponse
    Storage->>DB: SELECT columns (raw_response included)
    DB-->>Storage: row with raw_response JSON
    Storage-->>Gateway: StoredResponse(raw_response)
    Gateway->>Client: reconstruct history from raw_response["output"]
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • CatherineSue
  • slin1237

Poem

🐇 I hid four fields in a cozy JSON nest,
raw_response keeps them safe for any test.
Migrations hop through schema, tidy and spry —
Backends and routers read the bundle with a sigh.
A little rabbit cheers — data snug, carrot pie! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'refactor(data-connector): remove redundant fields from StoredResponse' clearly and accurately summarizes the main change: removing four redundant fields (output, metadata, instructions, tool_calls) from the StoredResponse struct across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch keyang/db-redundant-field

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

@github-actions github-actions Bot added grpc gRPC client and router changes tests Test changes data-connector Data connector crate changes model-gateway Model gateway crate changes openai OpenAI router changes labels Mar 2, 2026
@key4ng key4ng changed the title refactor(data-connector): consolidate response structure by removing … refactor(data-connector): remove redundant fields from StoredResponse Mar 2, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request streamlines the internal representation of stored responses by centralizing various response-related data into a single, flexible raw_response field. This change reduces redundancy in the data structure and simplifies database schemas, making the system more maintainable and adaptable to future changes in response formats. The update includes corresponding modifications to data handling logic and database migrations to ensure a smooth transition.

Highlights

  • Consolidated Response Structure: The StoredResponse struct has been refactored to remove individual fields such as output, instructions, tool_calls, and metadata. All this data is now consolidated into a single raw_response field, simplifying the data model.
  • Database Schema Updates: New database migration scripts have been introduced for both Oracle and PostgreSQL to drop the now-redundant columns (output, metadata, instructions, tool_calls) from the response storage tables, ensuring schema consistency with the new data model.
  • Codebase Adjustments: All related parsing functions, data access logic, and tests across the data_connector and model_gateway crates have been updated to reflect these changes, ensuring that data previously stored in separate fields is now correctly accessed from the raw_response field.
Changelog
  • data_connector/src/common.rs
    • Removed unused HashMap import.
    • Updated RESPONSE_COLUMNS constant to exclude instructions, output, tool_calls, and metadata.
    • Removed parse_tool_calls and parse_metadata utility functions.
    • Removed associated unit tests for parse_tool_calls and parse_metadata.
    • Adjusted a test assertion to reflect the removal of 'output' from core columns.
  • data_connector/src/core.rs
    • Removed instructions, output, tool_calls, and metadata fields from the StoredResponse struct.
    • Updated the StoredResponse::new constructor to no longer initialize the removed fields.
    • Modified ResponseChain::build_context to extract 'output' from the raw_response field.
    • Adjusted StoredResponse test cases to assert against raw_response instead of output for default values and content.
  • data_connector/src/hooked.rs
    • Updated test cases to store and retrieve 'output' data via the raw_response field.
  • data_connector/src/memory.rs
    • Modified test cases to store and retrieve 'output' data via the raw_response field.
    • Removed explicit setting of output for responses in various test scenarios.
  • data_connector/src/oracle.rs
    • Removed imports for parse_metadata and parse_tool_calls.
    • Updated core_cols array to exclude the removed response fields for schema definition.
    • Removed parsing logic for instructions, output, tool_calls, and metadata during response retrieval.
    • Removed the removed fields from StoredResponse construction and data insertion parameters.
  • data_connector/src/oracle_migrations.rs
    • Increased the number of Oracle migrations to include a new version.
    • Added a new migration (version 3) to drop output, metadata, instructions, and tool_calls columns.
    • Implemented oracle_v3_up function with PL/SQL to safely drop redundant columns.
    • Added unit tests for the new Oracle migration to verify column dropping logic.
  • data_connector/src/postgres.rs
    • Removed imports for parse_metadata and parse_tool_calls.
    • Updated core_cols array to exclude the removed response fields for schema definition.
    • Removed parsing logic for instructions, output, tool_calls, and metadata during response retrieval.
    • Removed the removed fields from StoredResponse construction and data insertion parameters.
  • data_connector/src/postgres_migrations.rs
    • Increased the number of PostgreSQL migrations to include a new version.
    • Added a new migration (version 3) to drop output, metadata, instructions, and tool_calls columns.
    • Implemented pg_v3_up function to drop redundant columns with DROP COLUMN IF EXISTS.
    • Added unit tests for the new PostgreSQL migration to verify column dropping logic and skipping behavior.
  • data_connector/src/redis.rs
    • Removed imports for parse_metadata and parse_tool_calls.
    • Removed parsing logic for instructions, output, tool_calls, and metadata during response retrieval.
    • Removed the removed fields from StoredResponse construction and Redis hash set operations.
    • Removed serialization of output, tool_calls, and metadata to JSON strings.
  • data_connector/src/schema.rs
    • Updated the RESPONSE_COLUMNS constant to remove instructions, output, tool_calls, and metadata.
  • model_gateway/src/routers/grpc/harmony/responses/common.rs
    • Updated load_previous_messages to retrieve 'output' from stored.raw_response.
  • model_gateway/src/routers/grpc/regular/responses/common.rs
    • Updated load_conversation_history to retrieve 'output' from stored.raw_response.
  • model_gateway/src/routers/openai/router.rs
    • Updated deserialize_items_from_array chain to retrieve 'output' from stored.raw_response.
  • model_gateway/src/routers/persistence_utils.rs
    • Removed initialization of stored.output and stored.instructions.
    • Removed logic for populating stored.instructions and stored.metadata.
    • Removed setting stored_response.output in persist_conversation_items.
  • model_gateway/tests/api/api_endpoints_test.rs
    • Updated test to set stored_response.raw_response with 'output' instead of stored_response.output.
  • model_gateway/tests/routing/test_openai_routing.rs
    • Updated test assertions to check raw_response["output"] instead of output.
    • Updated test to set raw_response with 'output' instead of output.
    • Adjusted assertions for metadata and instructions to access them through stored.raw_response.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the StoredResponse struct by removing dedicated fields for instructions, output, tool_calls, and metadata. These previously separate fields are now consolidated into the raw_response field, which stores the full raw JSON response. The changes include updating the StoredResponse definition, modifying data parsing and storage logic across Oracle, PostgreSQL, and Redis connectors, and adjusting related tests to access these values via raw_response["output"], raw_response["metadata"], etc. Database migrations (version 3) have been added for both Oracle and PostgreSQL to drop the redundant columns from their respective schemas, with safeguards to prevent dropping columns that are still in use via schema mappings or as extra columns. Review comments highlight an Insecure Direct Object Reference (IDOR) vulnerability in load_input_history, load_previous_messages, and load_conversation_history functions, recommending a dedicated pull request to address this cross-cutting security concern. Additionally, a suggestion was made to optimize the PostgreSQL migration by combining multiple DROP COLUMN statements into a single ALTER TABLE command for efficiency, which would also require updating the corresponding test case.

Comment thread model_gateway/src/routers/openai/router.rs
Comment thread model_gateway/src/routers/grpc/harmony/responses/common.rs
Comment thread model_gateway/src/routers/grpc/regular/responses/common.rs
Comment thread data_connector/src/postgres_migrations.rs
Comment thread data_connector/src/postgres_migrations.rs
…redundant columns and updating raw_response handling

This commit removes the `output`, `instructions`, `tool_calls`, and `metadata` fields from the `StoredResponse` struct and related parsing functions, consolidating response data into a single `raw_response` field. It also updates database migration scripts to drop the now-redundant columns from the schema. Tests and related code have been adjusted to reflect these changes, ensuring that output is accessed through `raw_response` instead.

Signed-off-by: key4ng <rukeyang@gmail.com>
@key4ng
key4ng force-pushed the keyang/db-redundant-field branch from 4963526 to 2dbf927 Compare March 2, 2026 21:08
@key4ng
key4ng marked this pull request as ready for review March 2, 2026 21:08
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

…tatement for redundant columns

This commit modifies the `pg_v3_up` function to consolidate the dropping of redundant columns into a single SQL statement. The function now checks for columns to drop and returns an empty vector if none are found. Additionally, the related test has been updated to reflect this change, ensuring it verifies the correct generation of the drop statement.

Signed-off-by: key4ng <rukeyang@gmail.com>

@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: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@data_connector/src/oracle_migrations.rs`:
- Around line 182-196: The test oracle_v3_up_skips_column_mapped_to_output
currently guards the content check with an if, allowing a silent pass when
oracle_v3_up returns no statements; change this to explicitly assert that the
returned stmts is non-empty (e.g., assert!(!stmts.is_empty(), "...")) and then
assert that stmts[0] does not contain "OUTPUT", so SchemaConfig setup and
oracle_v3_up behavior are validated instead of silently skipped.
- Around line 87-92: The current batch DROP generator uses a single ALTER TABLE
... DROP (cols) PL/SQL block (see the vector built from format! with
cols_to_drop) which causes ORA-00904 on a missing column to skip the entire
batch; change the generator to emit one PL/SQL drop block per column (iterate
cols_to_drop and produce a separate "BEGIN EXECUTE IMMEDIATE 'ALTER TABLE
{table} DROP (col)'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -904 THEN RAISE;
END IF; END;" for each col) so each missing column is ignored individually and
existing columns are still dropped, preserving idempotency for partial schema
states.

In `@data_connector/src/postgres_migrations.rs`:
- Around line 64-75: In pg_v3_up, the redundant field list ("output",
"metadata", "instructions", "tool_calls") is being treated as physical column
names; instead resolve each redundant field to its mapped physical name via
s.col(field) and then run the collision guards against that resolved name (check
s.columns.values() and s.extra_columns.keys() using the resolved column) and use
the resolved column in the ALTER TABLE DROP COLUMN IF EXISTS string; apply the
same change to the analogous block used later (the pg_v3_up redundant-columns
removal and the similar block at the other site) so we drop the actual mapped
physical columns rather than the logical field names.

In `@model_gateway/tests/routing/test_openai_routing.rs`:
- Around line 563-567: The test contains duplicated assertions for
stored.raw_response["metadata"]["topic"] == "unicorns" and
stored.raw_response["instructions"] == "Be kind"; remove the earlier duplicate
block (the assertions around stored.raw_response["metadata"]["topic"] and
stored.raw_response["instructions"] at lines 563–567) so only the later checks
remain, leaving a single assertion pair validating
stored.raw_response["metadata"]["topic"] and stored.raw_response["instructions"]
in the test containing the variable stored.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4aec6d and 2dbf927.

📒 Files selected for processing (16)
  • data_connector/src/common.rs
  • data_connector/src/core.rs
  • data_connector/src/hooked.rs
  • data_connector/src/memory.rs
  • data_connector/src/oracle.rs
  • data_connector/src/oracle_migrations.rs
  • data_connector/src/postgres.rs
  • data_connector/src/postgres_migrations.rs
  • data_connector/src/redis.rs
  • data_connector/src/schema.rs
  • model_gateway/src/routers/grpc/harmony/responses/common.rs
  • model_gateway/src/routers/grpc/regular/responses/common.rs
  • model_gateway/src/routers/openai/router.rs
  • model_gateway/src/routers/persistence_utils.rs
  • model_gateway/tests/api/api_endpoints_test.rs
  • model_gateway/tests/routing/test_openai_routing.rs
💤 Files with no reviewable changes (1)
  • data_connector/src/schema.rs

Comment thread data_connector/src/oracle_migrations.rs Outdated
Comment thread data_connector/src/oracle_migrations.rs Outdated
Comment thread data_connector/src/postgres_migrations.rs Outdated
Comment thread model_gateway/tests/routing/test_openai_routing.rs Outdated

@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: 1

♻️ Duplicate comments (1)
data_connector/src/postgres_migrations.rs (1)

60-82: ⚠️ Potential issue | 🟠 Major

pg_v3_up still doesn't resolve field names to physical column names.

The issue flagged in the prior review remains: for custom mappings like columns["output"] = "resp_output", this code attempts to drop the literal output column instead of the actual physical column resp_output. Use s.col(field) to resolve each redundant field to its physical name before applying guards and generating the DROP statement.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@data_connector/src/postgres_migrations.rs` around lines 60 - 82, pg_v3_up is
dropping logical field names (e.g., "output") instead of their physical column
names when column mappings exist; update the logic to call s.col(field) for each
entry in the redundant list so guards and DROP statements use the resolved
physical name. Specifically, for each field in redundant (the array in pg_v3_up)
call s.col(field) to get the actual column name, skip the drop if that resolved
name is present in s.columns or s.extra_columns (using the same
eq_ignore_ascii_case checks), and generate the DROP COLUMN IF EXISTS using the
resolved physical name when building cols_to_drop and the final ALTER TABLE
statement.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@data_connector/src/postgres_migrations.rs`:
- Around line 167-182: Rename the test pg_v3_up_skips_column_mapped_to_output to
pg_v3_up_skips_when_output_is_used_by_another_field to accurately reflect that
it covers the case where another field maps to the physical column "output";
then add a new test that sets
schema.responses.columns.insert("output".to_string(), "resp_output".to_string())
and calls pg_v3_up(&schema) asserting that the generated statement drops/handles
the mapped physical column ("resp_output") appropriately (e.g., contains
expected DROP/EXISTS logic for resp_output and not the logical "output"),
referencing SchemaConfig, responses.columns, and pg_v3_up to locate and
implement the new test.

---

Duplicate comments:
In `@data_connector/src/postgres_migrations.rs`:
- Around line 60-82: pg_v3_up is dropping logical field names (e.g., "output")
instead of their physical column names when column mappings exist; update the
logic to call s.col(field) for each entry in the redundant list so guards and
DROP statements use the resolved physical name. Specifically, for each field in
redundant (the array in pg_v3_up) call s.col(field) to get the actual column
name, skip the drop if that resolved name is present in s.columns or
s.extra_columns (using the same eq_ignore_ascii_case checks), and generate the
DROP COLUMN IF EXISTS using the resolved physical name when building
cols_to_drop and the final ALTER TABLE statement.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2dbf927 and 90d409b.

📒 Files selected for processing (1)
  • data_connector/src/postgres_migrations.rs

Comment thread data_connector/src/postgres_migrations.rs
…dually and update tests

This commit refines the `oracle_v3_up` function to drop redundant columns one at a time, ensuring that the absence of a column does not prevent others from being dropped. The filtering logic has been improved to check for column mappings and extra columns more effectively. Corresponding tests have been updated to reflect the new behavior, verifying that each redundant column is handled correctly.

Signed-off-by: key4ng <rukeyang@gmail.com>

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@data_connector/src/oracle_migrations.rs`:
- Around line 79-84: The skip logic incorrectly treats any other mapped field
(mapped_by_other_field) or extra column (used_as_extra) as a blocker even if
that other field/extra is also being dropped in the same migration; update the
condition so when computing mapped_by_other_field over s.columns and
used_as_extra over s.extra_columns you ignore keys that are in the current
migration's removal set (e.g., fields_being_removed / redundant_fields) — i.e.,
only count a mapping/extra as a blocker if the other key is not also scheduled
for removal; adjust the function signature or capture the existing removal list
and use it when evaluating mapped_by_other_field and used_as_extra.

In `@data_connector/src/postgres_migrations.rs`:
- Around line 68-83: The filter currently prevents dropping a physical column if
any other logical field maps to it—even if that other field is itself
redundant—causing shared redundant fields to block each other; update the
mapping check inside cols_to_drop so mapped_by_other_field only considers
non-redundant fields (i.e., ignore keys that are in the redundant set) when
testing s.columns for a value equal to s.col(field), while keeping the
used_as_extra check on s.extra_columns unchanged; locate the logic around
cols_to_drop, redundant, s.col, s.columns, and s.extra_columns and modify the
any(...) predicate to exclude keys present in redundant (and still
case-insensitively compare v to col).

In `@model_gateway/tests/routing/test_openai_routing.rs`:
- Line 490: The test seeds previous.raw_response["output"] as a string but the
suite expects the canonical array-of-output-items shape; update the seeded value
so previous.raw_response contains "output" as an array matching the persisted
response shape used elsewhere in tests (e.g., an array of output items/objects
rather than a bare string) so history/streaming fixtures mirror production
payloads and exercise load_input_history's array-handling.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90d409b and 410a3c1.

📒 Files selected for processing (3)
  • data_connector/src/oracle_migrations.rs
  • data_connector/src/postgres_migrations.rs
  • model_gateway/tests/routing/test_openai_routing.rs

Comment thread data_connector/src/oracle_migrations.rs Outdated
Comment thread data_connector/src/postgres_migrations.rs
Comment thread model_gateway/tests/routing/test_openai_routing.rs Outdated
…d pg_v3_up functions

This commit improves the column filtering logic in both the `oracle_v3_up` and `pg_v3_up` functions to exclude redundant fields when determining which columns to drop. The updated logic ensures that only non-redundant columns are considered for dropping, enhancing the accuracy of the migration scripts. Corresponding tests have been adjusted to validate these changes.

Signed-off-by: key4ng <rukeyang@gmail.com>
@slin1237
slin1237 merged commit 01a42fc into main Mar 2, 2026
25 checks passed
@slin1237
slin1237 deleted the keyang/db-redundant-field branch March 2, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data-connector Data connector crate changes grpc gRPC client and router changes model-gateway Model gateway crate changes openai OpenAI router changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants