-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
[BUG] Resource not found with dynamically created google spreadsheet #12637
base: master
Are you sure you want to change the base?
[BUG] Resource not found with dynamically created google spreadsheet #12637
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
@jcortes is attempting to deploy a commit to the Pipedreamers Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe updates to the Google Sheets actions include moving shared logic to a common module, restructuring import and export statements, updating the version numbers, and dynamically fetching worksheet titles instead of relying on static labels. These changes enhance code maintainability, error handling, and dynamic worksheet management across several actions such as adding, clearing, and updating rows and cells. Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
75f6ec5
to
297551c
Compare
297551c
to
1806984
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Outside diff range and nitpick comments (1)
components/google_sheets/actions/add-single-row/add-single-row.mjs (1)
Line range hint
116-118
: Redundant Else ClauseThe static analysis tool flagged the
else
clause as redundant because the previousif
statements already handle all possible outcomes by throwing exceptions.- } else if (Array.isArray(cells[0])) { - throw new ConfigurationError("Cell / Column data is a multi-dimensional array. A one-dimensional is expected. If you're trying to send multiple rows to Google Sheets, search for the action to add multiple rows to Sheets."); - }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (12)
- components/google_sheets/actions/add-multiple-rows/add-multiple-rows.mjs (4 hunks)
- components/google_sheets/actions/add-single-row/add-single-row.mjs (6 hunks)
- components/google_sheets/actions/clear-cell/clear-cell.mjs (3 hunks)
- components/google_sheets/actions/clear-rows/clear-rows.mjs (3 hunks)
- components/google_sheets/actions/common/worksheet.mjs (1 hunks)
- components/google_sheets/actions/find-row/find-row.mjs (4 hunks)
- components/google_sheets/actions/get-cell/get-cell.mjs (3 hunks)
- components/google_sheets/actions/get-values-in-range/get-values-in-range.mjs (3 hunks)
- components/google_sheets/actions/update-cell/update-cell.mjs (3 hunks)
- components/google_sheets/actions/update-multiple-rows/update-multiple-rows.mjs (4 hunks)
- components/google_sheets/actions/update-row/update-row.mjs (3 hunks)
- components/google_sheets/actions/upsert-row/upsert-row.mjs (7 hunks)
Additional context used
Biome
components/google_sheets/actions/add-single-row/add-single-row.mjs
[error] 116-118: This else clause can be omitted because previous branches break early.
Unsafe fix: Omit the else clause.
(lint/style/noUselessElse)
Additional comments not posted (33)
components/google_sheets/actions/common/worksheet.mjs (1)
8-10
: Review thegetWorksheetById
method implementation.The method uses
await
inside a destructuring assignment which is a good use of JavaScript features for readability and efficiency. However, ensure that error handling is robust, especially considering network requests can fail or return unexpected results.components/google_sheets/actions/get-cell/get-cell.mjs (1)
1-1
: Check the import path for the common module.Ensure the relative path in the import statement correctly points to the
common/worksheet.mjs
module. Path errors can cause runtime issues.Verification successful
Check the import path for the common module.
The correct relative path to the
worksheet.mjs
file should be../common/worksheet.mjs
as indicated by the search results.
components/google_sheets/actions/common/worksheet.mjs
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check if the path to 'common/worksheet.mjs' is correct. fd --type file "common/worksheet.mjs"Length of output: 37
Script:
#!/bin/bash # Description: Search for the worksheet.mjs file in the entire repository to verify its correct path. fd --type file "worksheet.mjs"Length of output: 416
components/google_sheets/actions/clear-cell/clear-cell.mjs (1)
48-51
: Ensure robust error handling inrun
method for clearing cell values.While the logic to clear cell values is correctly implemented, adding explicit error handling for API request failures would improve reliability.
components/google_sheets/actions/update-cell/update-cell.mjs (4)
1-3
: Standardized import structure approved.The change to import from the
common
module centralizes the functionality and enhances maintainability.
6-10
: Props restructuring approved.The inclusion of
...common
in the props reduces redundancy and ensures consistency across different modules.
10-10
: Version increment approved.Incrementing the version number following significant changes is a good practice to signal updates to users.
59-62
: Use ofgetWorksheetById
and request construction approved.The method fetches worksheet details correctly and constructs a well-formed request for updating a cell. Ensure that
getWorksheetById
is implemented correctly and tested.Verification successful
Let's correct the
ast-grep
pattern and also search for test cases to ensuregetWorksheetById
is properly implemented and tested.
To ensure thorough verification, let's broaden the search criteria to include different possible definitions and check for its usage within the codebase.
Let's extract and inspect the implementation of
getWorksheetById
fromcomponents/google_sheets/actions/common/worksheet.mjs
to verify its correctness.
Let's use
rg
to locate and display thegetWorksheetById
function definition withincomponents/google_sheets/actions/common/worksheet.mjs
.
Use of
getWorksheetById
and request construction approved.The method fetches worksheet details correctly and constructs a well-formed request for updating a cell. The
getWorksheetById
function is implemented correctly withincomponents/google_sheets/actions/common/worksheet.mjs
.
- Implementation found in
components/google_sheets/actions/common/worksheet.mjs
:async getWorksheetById(sheetId, worksheetId) { const { sheets } = await this.googleSheets.getSpreadsheet(sheetId); return sheets.find(({ properties: { sheetId } }) => String(sheetId) === String(worksheetId)); }Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `getWorksheetById`. # Test: Search for the function implementation. Expect: Correct implementation and testing. ast-grep --lang javascript --pattern $'async getWorksheetById($_, $_) { $$$ }'Length of output: 544
Script:
#!/bin/bash # Description: Verify the implementation and testing of `getWorksheetById`. # Search for the function implementation of `getWorksheetById` ast-grep --lang javascript --pattern 'async function getWorksheetById($_, $_) { $$$ }' # Also search for test cases related to `getWorksheetById` rg 'getWorksheetById' --glob '*test*'Length of output: 128
Script:
#!/bin/bash # Description: Verify the implementation and usage of `getWorksheetById`. # Search for the function implementation of `getWorksheetById` with different possible definitions ast-grep --lang javascript --pattern 'const getWorksheetById = async($_, $_) => { $$$ }' ast-grep --lang javascript --pattern 'async getWorksheetById($_, $_) { $$$ }' # Also search for its usage within the codebase to understand its context rg 'getWorksheetById'Length of output: 2820
Script:
#!/bin/bash # Extract and display the implementation of `getWorksheetById` from `components/google_sheets/actions/common/worksheet.mjs` ast-grep --lang javascript --pattern 'async getWorksheetById($_, $_) { $$$ }' components/google_sheets/actions/common/worksheet.mjsLength of output: 598
Script:
#!/bin/bash # Use `rg` to locate and display the `getWorksheetById` function definition within `components/google_sheets/actions/common/worksheet.mjs` rg 'async getWorksheetById' -A 10 -B 2 components/google_sheets/actions/common/worksheet.mjsLength of output: 352
components/google_sheets/actions/find-row/find-row.mjs (4)
1-3
: Standardized import structure approved.The change to import from the
common
module centralizes the functionality and enhances maintainability.
6-10
: Props restructuring approved.The inclusion of
...common
in the props reduces redundancy and ensures consistency across different modules.
10-10
: Version increment approved.Incrementing the version number following significant changes is a good practice to signal updates to users.
Line range hint
59-87
: Use ofgetWorksheetById
and dynamic data retrieval approved.The method fetches worksheet details correctly and uses dynamic data retrieval to find rows. Ensure that
getWorksheetById
is implemented correctly and tested.components/google_sheets/actions/update-row/update-row.mjs (4)
1-5
: Standardized import structure and utility imports approved.The change to import from the
common
module centralizes the functionality and enhances maintainability. Additionally, importing utilities likeConfigurationError
andparseArray
from a common module promotes code reuse.
8-12
: Props restructuring approved.The inclusion of
...common
in the props reduces redundancy and ensures consistency across different modules.
12-12
: Version increment approved.Incrementing the version number following significant changes is a good practice to signal updates to users.
70-73
: Use ofgetWorksheetById
and request construction approved.The method fetches worksheet details correctly and constructs a well-formed request for updating a row. Ensure that
getWorksheetById
is implemented correctly and tested.components/google_sheets/actions/update-multiple-rows/update-multiple-rows.mjs (4)
1-5
: Standardized import structure and utility imports approved.The change to import from the
common
module centralizes the functionality and enhances maintainability. Additionally, importing utilities likeparseArray
andgetWorksheetHeaders
from a common module promotes code reuse.
8-12
: Props restructuring approved.The inclusion of
...common
in the props reduces redundancy and ensures consistency across different modules.
12-12
: Version increment approved.Incrementing the version number following significant changes is a good practice to signal updates to users.
113-116
: Use ofgetWorksheetById
and request construction approved.The method fetches worksheet details correctly and constructs a well-formed request for updating multiple rows. Ensure that
getWorksheetById
is implemented correctly and tested.components/google_sheets/actions/add-multiple-rows/add-multiple-rows.mjs (4)
1-7
: Standardized import structure and utility imports approved.The change to import from the
common
module centralizes the functionality and enhances maintainability. Additionally, importing utilities likeConfigurationError
,parseArray
, andgetWorksheetHeaders
from a common module promotes code reuse.
10-14
: Props restructuring approved.The inclusion of
...common
in the props reduces redundancy and ensures consistency across different modules.
14-14
: Version increment approved.Incrementing the version number following significant changes is a good practice to signal updates to users.
106-109
: Use ofgetWorksheetById
and dynamic data addition approved.The method fetches worksheet details correctly and dynamically adds multiple rows to a spreadsheet. Ensure that
getWorksheetById
is implemented correctly and tested.Verification successful
Use of
getWorksheetById
and dynamic data addition approved.The method
getWorksheetById
is correctly implemented incomponents/google_sheets/actions/common/worksheet.mjs
. It fetches the spreadsheet details and finds the worksheet with the matchingworksheetId
.
components/google_sheets/actions/common/worksheet.mjs
:async getWorksheetById(sheetId, worksheetId) { const { sheets } = await this.googleSheets.getSpreadsheet(sheetId); return sheets.find(({ properties: { sheetId } }) => String(sheetId) === String(worksheetId)); },Scripts executed
The following scripts were executed for the analysis:
Script:
#!/binbash # Description: Verify the implementation of `getWorksheetById`. # Test: Search for the function implementation. Expect: Correct implementation and testing. ast-grep --lang javascript --pattern $'async getWorksheetById($_, $_) { $$$ }'Length of output: 544
Script:
#!/bin/bash # Description: Verify the implementation of `getWorksheetById`. # Test: Search for the function implementation. Expect: Correct implementation and testing. ast-grep --lang javascript --pattern 'function getWorksheetById($_, $_) { $$$ }' || ast-grep --lang javascript --pattern 'const getWorksheetById = async($_, $_) => { $$$ }' || ast-grep --lang javascript --pattern 'async function getWorksheetById($_, $_) { $$$ }'Length of output: 84
Script:
#!/bin/bash # Description: Verify the implementation of `getWorksheetById`. # Test: Search for the function implementation using ripgrep for broader search. rg 'getWorksheetById' --glob '*.js' --glob '*.mjs'Length of output: 2211
Script:
#!/bin/bash # Description: Extract and review the implementation of `getWorksheetById`. # Test: Extract the function implementation. rg -A 20 'async getWorksheetById' components/google_sheets/actions/common/worksheet.mjsLength of output: 329
components/google_sheets/actions/add-single-row/add-single-row.mjs (5)
1-1
: Refactor: Import and Prop ExtractionThe import of
common
and extraction ofgoogleSheets
fromcommon.props
are consistent with the PR's goal to centralize common functionality. This should help reduce redundancy and improve maintainability.Also applies to: 5-5
8-8
: Updated Action Metadata and VersioningThe action metadata has been updated to reflect the new functionality and the version has been incremented. This is good practice to help track changes and manage dependencies.
Also applies to: 12-12
57-59
: Enhanced Error Handling and Dynamic Data RetrievalThe use of
getWorksheetById
to fetch worksheet details dynamically and the improved error message when headers are missing are both positive changes. These adjustments enhance the robustness and user-friendliness of the module.
127-127
: Dynamic Range SpecificationThe dynamic setting of the
range
parameter based on the worksheet title aligns with the PR's objectives to handle worksheet data more flexibly and robustly.
133-133
: Summary Message GenerationThe generation of a detailed summary message that includes a link to the updated Google Sheet provides clear feedback to the user about the outcome of the operation.
components/google_sheets/actions/upsert-row/upsert-row.mjs (5)
2-2
: Refactor: Import and Prop ExtractionThe import of
common
and extraction ofgoogleSheets
fromcommon.props
are consistent with the PR's goal to centralize common functionality. This should help reduce redundancy and improve maintainability.Also applies to: 8-8
23-23
: Updated Action Metadata and VersioningThe action metadata has been updated to reflect the new functionality and the version has been incremented. This is good practice to help track changes and manage dependencies.
Also applies to: 27-27
108-108
: Dynamic Worksheet Handling and Error Handling ImprovementsThe use of
getWorksheetById
for dynamic worksheet handling, along with the dynamic range specification and improved error handling, aligns with the PR's objectives to handle worksheet data more flexibly and robustly.Also applies to: 135-135, 155-155, 167-167
135-135
: Formula Construction for Match OperationThe construction of a match formula to determine the presence of a duplicate key is a clever use of Google Sheets functionality. This allows for efficient upsert operations.
167-167
: Dynamic Update of Row Based on MatchThe dynamic updating of rows based on the match result ensures that data integrity is maintained, and only the intended rows are updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (2)
components/google_sheets/actions/find-row/find-row.mjs (1)
Line range hint
59-87
: Dynamic data fetching and error handling need attention.The dynamic fetching of column values and the condition
if (!this.exportRow)
could lead to issues ifexportRow
is not explicitly set. Consider adding a default value forexportRow
to ensure consistent behavior.- if (!this.exportRow) { + if (!this.exportRow || this.exportRow === false) { return result; }Also, ensure that the
worksheet
object always has theproperties
andtitle
fields before using them in the range construction.components/google_sheets/actions/add-single-row/add-single-row.mjs (1)
Line range hint
116-118
: Redundant Else Clause.The static analysis tool flagged that the else clause after an early return in the previous branches is redundant. Removing this could simplify the control flow.
- else if (Array.isArray(cells[0])) { - throw new ConfigurationError("Cell / Column data is a multi-dimensional array. A one-dimensional is expected. If you're trying to send multiple rows to Google Sheets, search for the action to add multiple rows to Sheets."); - }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (13)
- components/google_sheets/actions/add-multiple-rows/add-multiple-rows.mjs (4 hunks)
- components/google_sheets/actions/add-single-row/add-single-row.mjs (6 hunks)
- components/google_sheets/actions/clear-cell/clear-cell.mjs (3 hunks)
- components/google_sheets/actions/clear-rows/clear-rows.mjs (3 hunks)
- components/google_sheets/actions/common/worksheet.mjs (1 hunks)
- components/google_sheets/actions/find-row/find-row.mjs (4 hunks)
- components/google_sheets/actions/get-cell/get-cell.mjs (3 hunks)
- components/google_sheets/actions/get-values-in-range/get-values-in-range.mjs (3 hunks)
- components/google_sheets/actions/update-cell/update-cell.mjs (3 hunks)
- components/google_sheets/actions/update-multiple-rows/update-multiple-rows.mjs (4 hunks)
- components/google_sheets/actions/update-row/update-row.mjs (3 hunks)
- components/google_sheets/actions/upsert-row/upsert-row.mjs (7 hunks)
- components/google_sheets/package.json (1 hunks)
Files skipped from review due to trivial changes (1)
- components/google_sheets/package.json
Additional context used
Biome
components/google_sheets/actions/add-single-row/add-single-row.mjs
[error] 116-118: This else clause can be omitted because previous branches break early.
Unsafe fix: Omit the else clause.
(lint/style/noUselessElse)
Additional comments not posted (29)
components/google_sheets/actions/common/worksheet.mjs (1)
1-13
: Refactor and modularization of worksheet properties and methods.The introduction of
worksheet.mjs
as a common module for handling worksheet operations is a good practice for code reusability and maintainability. The methodgetWorksheetById
uses thefind
method on thesheets
array to matchsheetId
, which is a robust and straightforward way to locate the desired worksheet. Ensure that error handling is robust, particularly in cases where thesheets
array might be empty or thefind
method returnsundefined
.components/google_sheets/actions/get-cell/get-cell.mjs (1)
Line range hint
1-53
: Proper integration of common module and dynamic range calculation.The restructuring to use the
common
module fromworksheet.mjs
is well implemented. The dynamic calculation of the range in therun
method, which adjusts based on the presence ofworksheet?.properties?.title
, is a flexible approach that should handle various cases well. However, consider adding error handling for cases whereworksheet
might benull
orundefined
to prevent runtime errors.components/google_sheets/actions/get-values-in-range/get-values-in-range.mjs (1)
Line range hint
1-56
: Effective use of common properties and dynamic range handling.This module correctly implements the common properties and methods for fetching values in a range. The dynamic setting of the range based on whether a specific range is provided is a smart implementation detail that enhances the flexibility of the action. Again, ensure that there is error handling for
worksheet
beingnull
orundefined
.components/google_sheets/actions/clear-cell/clear-cell.mjs (1)
Line range hint
1-51
: Consistent use of common module and correct range specification.The use of the common module is consistent with other action modules, and the specific cell clearing functionality is correctly implemented with dynamic range calculation. The action properly constructs the request object for the API call. Ensure robust error handling for cases where the
worksheet
might not be correctly retrieved.components/google_sheets/actions/clear-rows/clear-rows.mjs (1)
Line range hint
1-57
: Well-implemented dynamic row clearing functionality.The module effectively uses the common properties and methods, and the dynamic range calculation for clearing rows is correctly handled. The use of optional
endIndex
to adjust the range dynamically is a thoughtful feature that adds flexibility to the action. As with other modules, ensure robust error handling for potential null values in theworksheet
.
[APROVED]components/google_sheets/actions/update-cell/update-cell.mjs (3)
1-3
: Refactoring to use common module is well-integrated.The import of
common
from../common/worksheet.mjs
and the extraction ofgoogleSheets
fromcommon.props
are consistent with the changes described in the summary.
59-62
: Optimization in dynamic range construction.Using the
worksheet?.properties?.title
to dynamically construct the range is a good use of optional chaining to prevent runtime errors. Ensure thatworksheet
always has theproperties
andtitle
fields populated.
6-10
: Check the version increment and spread operator usage.The version has been updated to "0.1.6", which should be verified against the versioning policy of the project. Also, the spread operator usage integrates common properties effectively, but ensure that it does not unintentionally override any existing props.
components/google_sheets/actions/find-row/find-row.mjs (2)
1-3
: Good integration of common module for consistency.The changes are consistent with the project's direction of using a common module for Google Sheets operations.
6-10
: Version and props restructuring handled well.The version update to "0.2.6" and restructuring of props using the common module are correctly implemented.
components/google_sheets/actions/update-row/update-row.mjs (2)
1-5
: Integration of common module and additional imports.The import of the common module and additional utilities like
ConfigurationError
andparseArray
are appropriately done, enhancing the module's functionality.
8-12
: Version update and props restructuring.The version has been updated, and the props have been restructured using the common module, maintaining consistency across the project.
components/google_sheets/actions/update-multiple-rows/update-multiple-rows.mjs (3)
1-5
: Proper use of common module and utility functions.The import of the common module along with utility functions like
parseArray
andgetWorksheetHeaders
enhances the functionality for handling multiple rows.
8-12
: Consistent version update and props integration.The version update and integration of props using the common module are consistent with the changes across other modules.
Line range hint
76-116
: Complex logic in handling multiple rows needs careful review.The logic for validating input and dynamically setting the range for multiple rows update is complex. Verify that all edge cases are handled, especially when
rows
is not an array of arrays.components/google_sheets/actions/add-multiple-rows/add-multiple-rows.mjs (3)
1-7
: Integration of common module and utility functions.The import of the common module along with utility functions enhances the module's functionality for adding multiple rows.
10-14
: Version update and props restructuring handled well.The version update and restructuring of props using the common module are correctly implemented.
Line range hint
75-109
: Dynamic row addition and formatting reset functionality.The dynamic addition of rows and the optional reset of row formatting are well-implemented, providing flexibility and enhanced functionality.
components/google_sheets/actions/add-single-row/add-single-row.mjs (5)
1-1
: Refactor: Import from common module.The change to import
common
from../common/worksheet.mjs
centralizes the shared functionality, which is a good practice for maintainability and reuse.
5-5
: Refactor: Consolidate Google Sheets properties.Extracting
googleSheets
fromcommon.props
ensures that all Google Sheets-related properties and methods are managed centrally, which enhances consistency across different modules.
8-12
: Refactor: Integrate common properties and update version.Incorporating
...common
into the export object allows for shared configurations and methods to be reused efficiently. Also, updating the version to "2.1.8" correctly reflects these significant changes.
[APROVED]
57-59
: Enhanced Error Handling in Header Row Check.The logic to check for the presence of a header row and throw a
ConfigurationError
if absent is a robust way to handle potential misconfigurations by the user. This preemptive error handling improves user experience by providing clear feedback.
127-127
: Dynamic Range Definition and Summary Generation.Using
worksheet?.properties?.title
for the range parameter dynamically adjusts the target based on the worksheet properties, which is a flexible approach. Additionally, the summary message generation provides useful feedback to the user about the action performed.Also applies to: 133-133
components/google_sheets/actions/upsert-row/upsert-row.mjs (6)
2-2
: Refactor: Import from common module.The change to import
common
from../common/worksheet.mjs
centralizes the shared functionality, which is a good practice for maintainability and reuse.
8-8
: Refactor: Consolidate Google Sheets properties.Extracting
googleSheets
fromcommon.props
ensures that all Google Sheets-related properties and methods are managed centrally, which enhances consistency across different modules.
23-27
: Refactor: Integrate common properties and update version.Incorporating
...common
into the export object allows for shared configurations and methods to be reused efficiently. Also, updating the version to "0.1.8" correctly reflects these significant changes.
108-108
: Dynamic Worksheet Handling.The use of
getWorksheetById
for dynamically fetching worksheet properties is a good practice, as it allows the action to adapt based on the actual worksheet configuration.
135-135
: Complex Formula Construction for Match Operation.Building a complex MATCH formula dynamically is a crucial part of the upsert functionality. This allows the action to intelligently determine whether to update an existing row or insert a new one based on the presence of a key.
155-155
: Dynamic Range and Worksheet Title Usage.Using
worksheet?.properties?.title
for the range dynamically adjusts the target based on the worksheet properties. This flexibility is crucial for the correct execution of the upsert logic.Also applies to: 167-167
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jcortes, LGTM! Ready for QA!
WHY
Removed withLabel field from worksheetId async props
Resolves #12301
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Version Updates