Skip to content

fix: clean metadata list before sending to backend in batch edit#32094

Open
jackjin1997 wants to merge 1 commit intolanggenius:mainfrom
jackjin1997:fix/metadata-batch-edit
Open

fix: clean metadata list before sending to backend in batch edit#32094
jackjin1997 wants to merge 1 commit intolanggenius:mainfrom
jackjin1997:fix/metadata-batch-edit

Conversation

@jackjin1997
Copy link

@jackjin1997 jackjin1997 commented Feb 8, 2026

Fixes #31964.

Addresses the issue where frontend-only fields (isUpdated, updateType, isMultipleValue) were being sent to the backend during batch metadata editing, causing validation failures.

This PR implements:

  • Explicit serialization of metadata objects to include only 'id', 'name', 'type', and 'value'.
  • Refactored 'apply to all' logic to prevent object reference pollution and duplicate fields.

Addressing Bot Feedback:

  • The PR has been rebased/cherry-picked to ensure it only contains the relevant frontend fix.
  • (Unrelated backend changes mentioned by the bot were from a stale base and have been removed).

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 8, 2026
@github-actions github-actions bot added the web This relates to changes on the web. label Feb 8, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jackjin1997, 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 addresses a critical bug in the batch metadata editing feature where frontend-specific fields were inadvertently included in the data sent to the backend, leading to validation failures. By implementing a strict serialization process that filters out these extraneous fields, the PR ensures that batch metadata updates can be performed successfully, improving the reliability of data management. Additionally, unrelated changes were made to the backend to handle re-signing of file URLs within conversation fields.

Highlights

  • Metadata Batch Edit Fix: Frontend-only fields like 'isUpdated' and 'updateType' are now explicitly excluded when sending metadata to the backend during batch edit operations, resolving validation errors.
  • Data Serialization Logic: The useBatchEditDocumentMetadata hook in the frontend has been updated to ensure that only essential metadata fields (id, name, type, value) are serialized and sent to the backend.
  • Backend File URL Re-signing (Unrelated): New functionality has been introduced in the backend to re-sign file URLs embedded within agent thoughts and observations, though this appears unrelated to the primary PR title and description.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • api/fields/conversation_fields.py
    • The thought and observation fields in the AgentThought model now use validation_alias to map to re_sign_file_url_thought and re_sign_file_url_observation respectively, indicating a change in how these fields are processed or validated.
  • api/models/model.py
    • A new private method _re_sign_file_url was added to parse text and re-sign any embedded file URLs (for tools, file previews, and image previews).
    • Two new properties, re_sign_file_url_thought and re_sign_file_url_observation, were introduced to apply the URL re-signing logic to the thought and observation attributes.
  • web/app/components/datasets/metadata/hooks/use-batch-edit-document-metadata.ts
    • The newMetadataList variable was changed from let to const for immutability.
    • Logic for adding new metadata items was updated to explicitly construct objects containing only id, name, type, and value fields.
    • The mapping logic for existing metadata items was also updated to explicitly return only id, name, type, and value, effectively stripping any frontend-only properties before submission.
    • The final list of metadata sent to the backend is now referred to as finalMetadataList.
Activity
  • No specific activity (comments, reviews, etc.) was provided in the context for this pull request.
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.

Copy link
Contributor

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

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 introduces backend logic to re-sign file URLs within agent thoughts and observations and fixes a frontend issue by cleaning metadata objects. However, it introduces a potential Regular Expression Denial of Service (ReDoS) vulnerability due to a greedy quantifier in the URL parsing regex. Additionally, a critical bug and areas for improvement have been identified in the new backend logic, along with opportunities to optimize the performance of the frontend data processing. The comment regarding IDOR testing is also misleading, as IDOR prevention should be handled at the authorization layer.

@jackjin1997 jackjin1997 force-pushed the fix/metadata-batch-edit branch from d01ea34 to d428fd8 Compare February 8, 2026 08:38
@jackjin1997
Copy link
Author

Cleaned up the PR by rebase/cherry-pick to remove unrelated commits and addressed the bot feedback.

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Feb 8, 2026
@jackjin1997 jackjin1997 force-pushed the fix/metadata-batch-edit branch from d428fd8 to 8660e66 Compare February 8, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

metadata batch edit doesn't work

1 participant