{"record":{"id":"66dd34c284014460","repo":"appsmithorg/appsmith","slug":"pe-arg-5000-66dd34","errorCode":"PE-ARG-5000","errorMessage":"Unexpected value for table header index. Please use a number starting from 1","messagePattern":"Unexpected value for table header index\\. Please use a number starting from 1","errorType":"exception","errorClass":"AppsmithPluginException","httpStatus":500,"severity":"error","filePath":"app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/GetStructureMethod.java","lineNumber":51,"sourceCode":"    public GetStructureMethod(ObjectMapper objectMapper) {\n        this.objectMapper = objectMapper;\n        this.filterDataService = FilterDataService.getInstance();\n    }\n\n    // Used to capture the range of columns in this request. The handling for this regex makes sure that\n    // all possible combinations of A1 notation for a range map to a common format\n    Pattern findAllRowsPattern = Pattern.compile(\"([a-zA-Z]*)\\\\d*:([a-zA-Z]*)\\\\d*\");\n\n    // The starting row for a range is captured using this pattern to find its relative index from table heading\n    Pattern findOffsetRowPattern = Pattern.compile(\"(\\\\d+):\");\n\n    @Override\n    public boolean validateExecutionMethodRequest(MethodConfig methodConfig) {\n        if (methodConfig.getTableHeaderIndex() != null\n                && !methodConfig.getTableHeaderIndex().isBlank()) {\n            try {\n                if (Integer.parseInt(methodConfig.getTableHeaderIndex()) <= 0) {\n                    throw new AppsmithPluginException(\n                            AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,\n                            ErrorMessages.INVALID_TABLE_HEADER_INDEX);\n                }\n            } catch (NumberFormatException e) {\n                throw new AppsmithPluginException(\n                        AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, ErrorMessages.INVALID_TABLE_HEADER_INDEX);\n            }\n        } else {\n            throw new AppsmithPluginException(\n                    AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, ErrorMessages.INVALID_TABLE_HEADER_INDEX);\n        }\n        return true;\n    }\n\n    @Override\n    public WebClient.RequestHeadersSpec<?> getExecutionClient(WebClient webClient, MethodConfig methodConfig) {\n\n        final List<String> ranges = validateInputs(methodConfig);","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/appsmithorg/appsmith/blob/8cd9021c24cdbea1c3c12c966073708e83db60c2/app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/config/GetStructureMethod.java#L33-L69","documentation":"Thrown by GetStructureMethod.validateExecutionMethodRequest (GetStructureMethod.java:51) when `tableHeaderIndex` is a valid integer but is `<= 0`. The table header index marks the 1-based row that holds column headers, so zero or negative values are invalid. Code PE-ARG-5000 (INVALID_TABLE_HEADER_INDEX).","triggerScenarios":"The 'Get Structure' / read action runs with `tableHeaderIndex` set to `0`, a negative number, or a numeric expression that evaluates to <= 0 (e.g. `{{rowIdx - 5}}` when rowIdx is small). `Integer.parseInt` succeeds, then the `<= 0` branch throws.","commonSituations":"User assumes a 0-based row index and enters `0`; a mustache binding computes the index and underflows (e.g. `{{currentIndex - offset}}`); default value mistakenly set to `0`; copying config from a row-index field (which is 0-based) into the header-index field (1-based).","solutions":["Set `tableHeaderIndex` to a 1-based row number, e.g. `1` if headers are in the first row.","If computing dynamically, clamp the result to at least 1: `Math.max(1, currentIndex)`.","Remember: table header index is 1-based, unlike the separate row-index field which is 0-based."],"exampleFix":"// before\n{\n  \"tableHeaderIndex\": 0   // 0-based mistake\n}\n// after\n{\n  \"tableHeaderIndex\": 1   // 1-based: first row holds headers\n}","handlingStrategy":"validation","validationCode":"// Clamp any computed header index to a 1-based positive integer before submit.\nfunction headerIndex(value) {\n  const n = Math.trunc(Number(value));\n  return Number.isFinite(n) && n >= 1 ? String(n) : \"1\";\n}\n// Bind tableHeaderIndex: {{ headerIndex(someWidget.value) }}","typeGuard":"function isValidHeaderIndex(v) {\n  const n = Number(v);\n  return Number.isInteger(n) && n >= 1;\n}","tryCatchPattern":"if (getStructure.error && /table header index/.test(getStructure.error.message)) {\n  showToast(\"Table header index must be a whole number >= 1.\", \"error\");\n}","preventionTips":["Treat table header index as 1-based (unlike row-index fields which are 0-based).","Clamp dynamically computed indices with Math.max(1, n).","Default the field to 1 for typical first-row headers."],"tags":["google-sheets","appsmith","input-validation","get-structure","table-header-index"],"backgroundTag":null,"analyzedSha":"8cd9021c24cdbea1c3c12c966073708e83db60c2","analyzedAt":"2026-08-12T22:14:19.293Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}