Skip to content

Google drive - adding 'metadata' prop to 'upload file' action #16949

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: master
Choose a base branch
from

Conversation

GTFalcao
Copy link
Collaborator

@GTFalcao GTFalcao commented Jun 3, 2025

Closes #16814

Summary by CodeRabbit

  • New Features
    • Added support for including optional metadata when uploading files to Google Drive.
  • Improvements
    • The file ID is now optional when uploading files to Google Drive, with a clearer description.
  • Style
    • Added newline characters to several component files for improved formatting.

Copy link

vercel bot commented Jun 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Jun 3, 2025 8:41pm
pipedream-docs ⬜️ Ignored (Inspect) Jun 3, 2025 8:41pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jun 3, 2025 8:41pm

Copy link
Contributor

coderabbitai bot commented Jun 3, 2025

"""

Walkthrough

The changes introduce an optional metadata property to the Google Drive "Upload File" action, allowing users to specify additional file metadata during upload. Utility functions for parsing metadata as JSON were added. Minor formatting changes (newline additions) were made to several unrelated files, with no impact on their logic.

Changes

Files/Group Change Summary
components/google_drive/actions/upload-file/upload-file.mjs Added optional metadata prop, updated version to 1.1.0, made fileId optional, integrated metadata parsing and inclusion in upload API calls.
components/google_drive/common/utils.mjs Added and exported optionalParseAsJSON and parseObjectEntries utility functions for metadata parsing.
components/action1/action1.app.mjs,
components/buddy/buddy.app.mjs,
components/guardrails/guardrails.app.mjs,
components/local_reviews/local_reviews.app.mjs
Added newline at end of file; no functional changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UploadFileAction
    participant Utils
    participant GoogleDriveAPI

    User->>UploadFileAction: Provide file, (optional) metadata, (optional) fileId
    UploadFileAction->>Utils: parseObjectEntries(metadata)
    Utils-->>UploadFileAction: Parsed metadata object
    UploadFileAction->>GoogleDriveAPI: Upload or update file with file and metadata
    GoogleDriveAPI-->>UploadFileAction: Response
    UploadFileAction-->>User: Result
Loading

Assessment against linked issues

Objective Addressed Explanation
Add metadata prop to Google Drive Upload File action (#16814)
Parse and include metadata in file upload API call (#16814)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Addition of newline at end of unrelated files (components/action1/action1.app.mjs, components/buddy/buddy.app.mjs, components/guardrails/guardrails.app.mjs, components/local_reviews/local_reviews.app.mjs) These formatting changes are unrelated to the metadata feature request in the linked issue.

Poem

Hopping through code, a new field appears,
Metadata for files—let's all give three cheers!
With JSON parsed swiftly, uploads now gleam,
While newlines sneak in, like a soft bunny dream.
🐇✨
Code grows and hops, as features take flight—
Google Drive’s uploads now feel just right!
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/google_drive/actions/upload-file/upload-file.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:170:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cbbfc7b and c32ac66.

📒 Files selected for processing (2)
  • components/google_drive/actions/upload-file/upload-file.mjs (6 hunks)
  • components/google_drive/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/google_drive/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/google_drive/actions/upload-file/upload-file.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
components/google_drive/common/utils.mjs (1)

260-266: Consider input type validation for robust error handling.

The function works correctly for most cases, but consider adding input type validation to handle edge cases more explicitly. For non-string inputs, JSON.parse() will throw an error that gets caught and the original value returned, which might not be the intended behavior.

Consider this enhanced version for better type safety:

 function optionalParseAsJSON(value) {
+  if (typeof value !== "string") {
+    return value;
+  }
   try {
     return JSON.parse(value);
   } catch (e) {
     return value;
   }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7211d1 and 4218008.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • components/google_drive/actions/upload-file/upload-file.mjs (6 hunks)
  • components/google_drive/common/utils.mjs (2 hunks)
  • components/google_drive/package.json (1 hunks)
🔇 Additional comments (7)
components/google_drive/common/utils.mjs (1)

295-295: LGTM! Export statement correctly includes the new function.

The new parseObjectEntries function is properly exported alongside the existing utilities.

components/google_drive/package.json (1)

3-3: Appropriate version bump for new feature addition.

The version increment from "0.9.1" to "0.9.2" correctly follows semantic versioning for the addition of new utility functions and metadata support in the upload-file action.

components/google_drive/actions/upload-file/upload-file.mjs (5)

6-6: LGTM! Import statement correctly adds the new utility function.

The parseObjectEntries function is properly imported from the utils module and will be used for processing the metadata input.


17-17: Appropriate version increment for new feature.

The version bump from "1.0.2" to "1.1.0" correctly follows semantic versioning for the addition of the new metadata functionality.


120-120: LGTM! Metadata parsing implementation is correct.

The parseObjectEntries function is used appropriately to process the metadata input, ensuring JSON values are parsed while maintaining the object structure.


132-132: LGTM! Metadata properly integrated into API calls.

The parsed metadata is correctly passed as requestBody to both the file update (updateFile) and file creation (createFile) operations, ensuring consistent behavior across both code paths.

Also applies to: 143-143


88-96:

✅ Verification successful

Fix typo in metadata description and verify Google Drive API compatibility.

There's a typo in the description: "availabl efields" should be "available fields". Also, ensure that the metadata format aligns with Google Drive API expectations.

Fix the typo:

-      description: "Additional metadata to supply in the upload. [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/files) for information on availabl efields. Values will be parsed as JSON where applicable. Example: `{ \"description\": \"my file description\" }`",
+      description: "Additional metadata to supply in the upload. [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/files) for information on available fields. Values will be parsed as JSON where applicable. Example: `{ \"description\": \"my file description\" }`",

Let me verify that the Google Drive API accepts metadata in the requestBody format:


🏁 Script executed:

#!/bin/bash
# Description: Check Google Drive API documentation for file metadata format

# Search for how metadata is passed in file creation/update operations
rg -A 10 -B 5 "requestBody.*metadata\|metadata.*requestBody" components/google_drive/

Length of output: 87


🏁 Script executed:

#!/bin/bash
# Inspect how metadata is defined and passed to the Drive API in upload-file.mjs

echo "===== Snippet around metadata option ====="
rg -n "metadata" -C5 components/google_drive/actions/upload-file/upload-file.mjs || true

echo
echo "===== Drive API calls in upload-file.mjs ====="
rg -n "files\\.create" -C5 components/google_drive/actions/upload-file/upload-file.mjs || true
rg -n "files\\.update" -C5 components/google_drive/actions/upload-file/upload-file.mjs || true

echo
echo "===== First 200 lines of upload-file.mjs for context ====="
sed -n '1,200p' components/google_drive/actions/upload-file/upload-file.mjs || true

Length of output: 6486


🏁 Script executed:

#!/bin/bash
# Inspect how the wrapper passes metadata to the Drive API

echo "===== Looking into createFile method ====="
rg -n "createFile" -C10 components/google_drive/google_drive.app.mjs || true

echo
echo "===== Looking into updateFile method ====="
rg -n "updateFile" -C10 components/google_drive/google_drive.app.mjs || true

Length of output: 3689


Fix typo in metadata description

The metadata is correctly passed to the Drive API via the requestBody option, matching the expected format.

• File: components/google_drive/actions/upload-file/upload-file.mjs
• Lines: 93–96

-      description: "Additional metadata to supply in the upload. [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/files) for information on availabl efields. Values will be parsed as JSON where applicable. Example: `{ \"description\": \"my file description\" }`",
+      description: "Additional metadata to supply in the upload. [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/files) for information on available fields. Values will be parsed as JSON where applicable. Example: `{ \"description\": \"my file description\" }`",

Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

[FEATURE] Google Drive - Upload File: Add Metadata prop
2 participants