Skip to content

Fix bug metadata named params #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

prajwal-pai77
Copy link
Collaborator

Fix for Bugs: User Named params doesn't support other data types and Wrong expiration being shown in Show metadata option.

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.

Hello @prajwal-pai77, 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!

Summary of Changes

Hello! Gemini here, providing a summary of this pull request. This PR addresses two specific bug fixes for the Couchbase VS Code extension. Firstly, it resolves an issue where user-defined named parameters were incorrectly restricted to only string values, preventing the use of other data types like numbers, booleans, objects, or arrays. Secondly, it fixes a bug related to displaying document metadata, specifically ensuring the correct expiration time is shown when using the 'Show metadata' option.

Highlights

  • Enhanced Named Parameter Support: The configuration schema and parsing logic for user-defined named parameters (workbench.userNamedParameters) have been updated to correctly handle and utilize values of various data types, including strings, numbers, booleans, objects, and arrays. This allows for more flexible query execution.
  • Corrected Document Metadata Display: The N1QL query used to fetch document metadata has been modified to ensure accurate retrieval of metadata fields, including the document's expiration time, resolving a bug where incorrect expiration information was previously displayed.

Changelog

Click here to see the changelog
  • package-lock.json
    • Updated the extension version from 2.2.7 to 2.2.8.
  • package.json
    • Updated the extension version from 2.2.7 to 2.2.8.
    • Modified the configuration schema for workbench.userNamedParameters to allow values of type string, number, boolean, object, or array.
  • src/commands/documents/getDocumentMetaData.ts
    • Changed the N1QL query from SELECT META(b).* to SELECT META(b) as meta, XATTRS(b) as xattrs to fetch both standard metadata and extended attributes, improving metadata display accuracy.
  • src/types/IKeyValuePair.ts
    • Updated the value property type in the IKeyValuePair interface from string to any to support diverse data types for key-value pairs, aligning with named parameter changes.
  • src/util/namedParameters.ts
    • Updated the function to retrieve user-defined named parameters to handle and parse non-string values and JSON strings, allowing the use of various data types as parameter values.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


Named params now take all,
Strings, numbers, stand up tall,
Metadata shines bright,
Expiration shown right,
No more bugs to enthrall.

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

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@prajwal-pai77
Copy link
Collaborator Author

/gemini review

@@ -2,7 +2,7 @@
"name": "vscode-couchbase",
"displayName": "Couchbase",
"description": "",
"version": "2.2.7",
"version": "2.2.8",
Copy link
Contributor

Choose a reason for hiding this comment

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

These numberings are too confusing. Plus we need to start from 2.2.4 (Whatever was last release version)

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 effectively addresses two bugs: enabling support for various data types in User Named Parameters and correcting the display of expiration metadata. The changes in package.json, IKeyValuePair.ts, and namedParameters.ts work together well to allow diverse types for named parameters. The modification to the N1QL query in getDocumentMetaData.ts to explicitly fetch META() and XATTRS() is a good improvement for data consistency and likely resolves the expiration display issue. The code is clear and the fixes are well-targeted. Great work!

Summary of Findings

  • Support for Diverse Data Types in Named Parameters: The changes successfully implement support for non-string data types (number, boolean, object, array) in user-defined named parameters. This was achieved by updating the package.json schema, modifying the IKeyValuePair interface, and adjusting the logic in getUsersNamedParameters to handle pre-parsed types and attempt JSON.parse on string values.
  • Metadata Fetching for Expiration Display: The N1QL query in getDocumentMetaData.ts was updated to SELECT META(b) as meta, XATTRS(b) as xattrs .... This provides a more structured and explicit way to fetch document metadata and extended attributes, which should resolve the issue of incorrect expiration data being shown. This also aligns the data structure with the fallback KV path.
  • JSON Parsing Fallback in Named Parameters (Low Severity): In src/util/namedParameters.ts, when attempting to JSON.parse a string value for a named parameter, if parsing fails, it currently falls back to using the original string value without logging the parsing error. While this is a safe fallback, consider adding a console.warn or similar log in the catch block (around line 23-25). This could help users debug if they accidentally provide an invalid JSON string for a parameter. (No review comment added as per severity settings).

Merge Readiness

The pull request appears to be in good shape and ready for merging. The changes are well-implemented and address the described bugs effectively. As I am an AI assistant, I am not authorized to approve pull requests. Please ensure that other reviewers approve this code before merging.

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.

2 participants