Skip to content

fix: properly encode sheet names with special characters in Google Sheets integration#41773

Open
aayushbaluni wants to merge 2 commits intoappsmithorg:releasefrom
aayushbaluni:fix/41536-sheets-plus-encoding
Open

fix: properly encode sheet names with special characters in Google Sheets integration#41773
aayushbaluni wants to merge 2 commits intoappsmithorg:releasefrom
aayushbaluni:fix/41536-sheets-plus-encoding

Conversation

@aayushbaluni
Copy link
Copy Markdown

@aayushbaluni aayushbaluni commented May 1, 2026

Problem

Google Sheets spreadsheets.values.batchGet requests send sheet ranges via repeated ranges query parameters. Spring built those URIs with default encoding, which left a literal + in an A1 range (for example in the quoted sheet title). Many servers decode + as a space in query strings, so the API saw the wrong sheet name.

Change

  • Encode each range with application/x-www-form-urlencoded rules (URLEncoder) before attaching it as a query parameter, so + is sent as %2B.
  • Call UriComponentsBuilder.build(true) so values are not double-encoded (consistent with other methods in this plugin that combine encoded path segments with query params).

Testing

  • Added GoogleSheetsApiEncodingTest asserting encoded output contains %2B and no literal + for a sample range.

Fixes #41536.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed handling of special characters in Google Sheets range parameters to ensure proper encoding in API queries, resolving issues with sheets containing characters like "+".
  • Tests

    • Added test coverage for query parameter encoding validation.

…names

Use application/x-www-form-urlencoded encoding for ranges on values:batchGet
so a literal + in sheet titles is sent as %2B instead of being decoded as space.

Fixes appsmithorg#41536
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e4f272ed-bf2f-46c6-a72a-fd8b5deac439

📥 Commits

Reviewing files that changed from the base of the PR and between 2fa7210 and 38cac25.

📒 Files selected for processing (3)
  • app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/GetStructureMethod.java
  • app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsGetMethod.java
  • app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/utils/GoogleSheetsApiEncoding.java
✅ Files skipped from review due to trivial changes (3)
  • app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/utils/GoogleSheetsApiEncoding.java
  • app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsGetMethod.java
  • app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/GetStructureMethod.java

Walkthrough

A new utility encodes Google Sheets API query parameter values; GetStructureMethod and RowsGetMethod now encode A1 ranges and build URIs with the builder's encoded mode. A unit test verifies plus signs are percent-encoded.

Changes

Google Sheets query-parameter encoding

Layer / File(s) Summary
Data Shape / Utility
app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/utils/GoogleSheetsApiEncoding.java
Adds GoogleSheetsApiEncoding with encodeQueryParameter(String) that URL-encodes using UTF-8 and normalizes + handling; class is final with a private constructor.
Core Usage
app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/GetStructureMethod.java
Calls GoogleSheetsApiEncoding::encodeQueryParameter for each validated range, uses encodedRanges in ranges query param, switches URI build to uriBuilder.build(true).
Core Usage
app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/RowsGetMethod.java
Encodes computed spreadsheet ranges via GoogleSheetsApiEncoding::encodeQueryParameter before adding to ranges query param and changes URI build to uriBuilder.build(true); request semantics unchanged (majorDimension=ROWS, GET).
Tests
app/server/appsmith-plugins/googleSheetsPlugin/src/test/java/com/external/utils/GoogleSheetsApiEncodingTest.java
Adds JUnit 5 test asserting a sheet-name containing + is encoded to include %2B and not a literal +.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A plus once slipped through query's gate,
Now percent-encoded — tidy and straight.
Ranges travel safe in their URL gown,
Sheets salute; no more breakdown. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing encoding of sheet names with special characters in the Google Sheets integration.
Description check ✅ Passed The description clearly explains the problem, the solution, and testing approach, with reference to issue #41536, meeting template requirements.
Linked Issues check ✅ Passed The PR directly addresses issue #41536 by encoding sheet names with special characters (specifically +) to prevent API failures.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the encoding issue: utility class for encoding, updates to GetStructureMethod and RowsGetMethod, and corresponding tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

[Bug]: Google Spreadsheet won't load if a list contains plus "+" character

1 participant