Skip to content

fix(schema): keep repeated query metadata and honor array params#301

Open
sonwr wants to merge 1 commit intogoogleworkspace:mainfrom
sonwr:fix/schema-repeated-query-300
Open

fix(schema): keep repeated query metadata and honor array params#301
sonwr wants to merge 1 commit intogoogleworkspace:mainfrom
sonwr:fix/schema-repeated-query-300

Conversation

@sonwr
Copy link

@sonwr sonwr commented Mar 8, 2026

This fixes #300.

gws schema now preserves repeated: true for method parameters, and request execution now expands JSON array values into repeated query keys for parameters marked as repeated in discovery docs.

Example behavior after this change:

  • metadataHeaders appears with repeated: true in gws schema gmail.users.messages.get
  • --params '{"metadataHeaders":["Subject","Date","From"]}' sends repeated query pairs

Verification:

  • ~/.cargo/bin/cargo test test_param_to_json -- --nocapture
  • ~/.cargo/bin/cargo test test_build_url_ -- --nocapture
  • ~/.cargo/bin/cargo run -- schema gmail.users.messages.get (confirmed metadataHeaders.repeated=true in output)

@sonwr sonwr requested a review from jpoehnelt as a code owner March 8, 2026 05:04
@changeset-bot
Copy link

changeset-bot bot commented Mar 8, 2026

⚠️ No Changeset found

Latest commit: e1c0961

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@googleworkspace-bot googleworkspace-bot added area: http area: core Core CLI parsing, commands, error handling, utilities labels Mar 8, 2026
@gemini-code-assist
Copy link
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 refines the handling of repeated query parameters within the API client. It ensures that the generated schema accurately reflects whether a parameter can be repeated and modifies the request builder to correctly serialize array values into multiple key-value pairs for such parameters, aligning with standard API conventions for repeated query parameters.

Highlights

  • Schema Generation: The generated JSON schema for method parameters now correctly includes the repeated: true flag when applicable, ensuring accurate metadata representation.
  • Query Parameter Handling: Request execution logic has been enhanced to properly expand JSON array values into multiple query parameters for method parameters explicitly marked as repeated in discovery documents.
Changelog
  • src/executor.rs
    • Refactored the query_params field in the ExecutionInput struct and the build_url function signature from HashMap<String, String> to Vec<(String, String)> to allow for multiple query parameters with the same key.
    • Implemented new logic within the build_url function to detect repeated method parameters and, if their value is a JSON array, iterate through the array to add each item as a separate (key, value) pair to the query_params vector.
    • Added a new test case, test_build_url_repeated_query_params_from_array, to verify the correct expansion of array values into repeated query parameters.
    • Updated existing test cases to use Vec::new() for initializing query_params where appropriate.
  • src/schema.rs
    • Modified the param_to_json function to include the "repeated": true field in the generated JSON output for method parameters that have their repeated property set to true.
    • Adjusted the test_param_to_json test to set repeated: true for a sample MethodParameter and assert that the generated JSON includes "repeated": true.
Activity
  • The author provided detailed verification steps, including output from test schema::tests::test_param_to_json and test executor::tests::test_build_url_repeated_query_params_from_array, confirming the fixes.
  • The verification output included a snippet of a Gmail API method definition, demonstrating a repeated: true parameter (metadataHeaders), which was used to validate the new functionality.
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 Generative AI Prohibited Use Policy, 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 implements support for repeated query parameters by modifying query_params to be a Vec of tuples in src/executor.rs, which allows for multiple query parameters with the same key. The logic in build_url is updated to expand array values for parameters marked as repeated. The changes also update src/schema.rs to include the repeated field in the schema output. The new functionality is covered by tests. I have not identified any issues of high or critical severity.

@jpoehnelt
Copy link
Member

can you add a changeset

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 96.49123% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.23%. Comparing base (95bb24e) to head (e1c0961).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
src/executor.rs 96.15% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #301      +/-   ##
==========================================
+ Coverage   59.09%   59.23%   +0.14%     
==========================================
  Files          36       36              
  Lines       12953    13002      +49     
==========================================
+ Hits         7654     7702      +48     
- Misses       5299     5300       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

area: core Core CLI parsing, commands, error handling, utilities area: http

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gws schema drops repeated: true for array query parameters, causing metadata format to fail

3 participants