Skip to content
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

Sheets V4 append with sheet name including "+" broken since google-http-client version 1.34.0 #1573

Open
mihalyr opened this issue Feb 3, 2022 · 1 comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@mihalyr
Copy link

mihalyr commented Feb 3, 2022

As reported at https://issuetracker.google.com/issues/217399871

The sheets.spreadsheets().values().append operation is failing if the sheet name includes a plus ("+") sign and has a dependency on google-http-client version 1.34.0 or older.

The breaking change is likely the result of #913

Library versions:

    implementation 'com.google.apis:google-api-services-drive:v2-rev212-1.21.0'
    implementation 'com.google.apis:google-api-services-sheets:v4-rev612-1.25.0'
    testImplementation 'com.google.api-client:google-api-client:1.25.0'
    testImplementation 'com.google.http-client:google-http-client:1.34.0'
    testImplementation 'com.google.http-client:google-http-client-jackson2:1.34.0'

Reproducer:

    @Test
    void testAppendWithPlusSignSheet() throws Exception {
        String fileName = "test-append-plus-sign";
        String sheetName = "plus+sign";
        String spreadsheetId = spreadsheetHelper.createSpreadsheet(fileName, sheetName);

        String range = sheetName + "!A1";
        ValueRange valueRange = new ValueRange();
        valueRange.setMajorDimension(SheetOptions.MAJOR_DIMENSION_ROWS);
        valueRange.setRange(range);
        valueRange.setValues(ImmutableList.of(ImmutableList.of("test")));

        try {
            Sheets sheets = authHelper.getSheetsService();

            sheets.spreadsheets().values()
                    .append(spreadsheetId, range, valueRange)
                    .setValueInputOption(SheetOptions.VALUE_INPUT_RAW)
                    .setInsertDataOption(SheetOptions.INSERT_DATA_ROWS)
                    .setIncludeValuesInResponse(true)
                    .setResponseValueRenderOption(SheetOptions.VALUE_RENDERING_UNFORMATTED)
                    .setResponseDateTimeRenderOption(SheetOptions.DATE_RENDERING_SERIAL)
                    .execute();
        } finally {
            Drive drive = authHelper.getDriveService();
            FileList fileList = drive.files().list().execute();
            for (File file : fileList.getItems()) {
                if (file.getTitle().equals(sheetTitle)) {
                    drive.files().delete(file.getId()).execute();
                }
            }
        }
    }

This was working fine up to google-http-client version 1.33.0, when used with a newer version it fails with the following exception:

    com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
    {
      "code" : 400,
      "errors" : [ {
        "domain" : "global",
        "message" : "Request range[plus sign!A1] does not match value's range[plus+sign!A1]",
        "reason" : "badRequest"
      } ],
      "message" : "Request range[plus sign!A1] does not match value's range[plus+sign!A1]",
      "status" : "INVALID_ARGUMENT"
    }
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Feb 4, 2022
@lesv lesv added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed triage me I really want to be triaged. labels Feb 7, 2022
@lesv lesv transferred this issue from googleapis/google-api-java-client Feb 7, 2022
@lesv lesv added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Feb 7, 2022
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels May 8, 2022
@diegomarquezp diegomarquezp self-assigned this Sep 7, 2022
@meltsufin meltsufin added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Sep 12, 2022
@diegomarquezp diegomarquezp removed their assignment Feb 22, 2023
@mihalyr
Copy link
Author

mihalyr commented Feb 26, 2024

Hey there, just chiming in that today we updated to the latest Sheets V4 java package that uses com.google.http-client:google-http-client:1.42.3 and we are still facing this issue with the plus sign. The only workaround for us is to add the sign to some unallowed character list and prevent our users creating sheets with such names. This is a bit awkward as there might be users already with plus signs and this defect will force them to make changes to their sheets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

5 participants