{"record":{"id":"a02b7649fc3bcf87","repo":"temporalio/temporal","slug":"error-reading-contents-unmatched-begin-keyword","errorCode":null,"errorMessage":"error reading contents: unmatched `BEGIN` keyword","messagePattern":"error reading contents: unmatched `BEGIN` keyword","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/persistence/query_util.go","lineNumber":182,"sourceCode":"\t\t\t\t\tif j+len(sqlLineComment) <= n && contentStr[j:j+len(sqlLineComment)] == sqlLineComment {\n\t\t\t\t\t\t_, _ = stmtBuilder.Write(bytes.TrimRight(content[i:j], \" \"))\n\t\t\t\t\t\tfor j < n && contentStr[j] != '\\n' {\n\t\t\t\t\t\t\tj++\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti = j\n\t\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\t// no-op: generic character\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif len(st) > 0 {\n\t\t\t\tswitch st[len(st)-1] {\n\t\t\t\tcase sqlLeftParenthesis:\n\t\t\t\t\treturn nil, fmt.Errorf(\"error reading contents: unmatched left parenthesis\")\n\t\t\t\tcase sqlBeginKeyword[0]:\n\t\t\t\t\treturn nil, fmt.Errorf(\"error reading contents: unmatched `BEGIN` keyword\")\n\t\t\t\tdefault:\n\t\t\t\t\t// should never enter here\n\t\t\t\t\treturn nil, fmt.Errorf(\"error reading contents: unmatched `%c`\", st[len(st)-1])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_, _ = stmtBuilder.Write(content[i:j])\n\t\t\tstmt := strings.TrimSpace(stmtBuilder.String())\n\t\t\tif stmt == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tresult = append(result, stmt)\n\t\t}\n\t}\n\treturn result, nil\n}\n\n// hasWordAt is a simple test to check if it matches the whole word:","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/persistence/query_util.go#L164-L200","documentation":"Error \"error reading contents: unmatched `BEGIN` keyword\" thrown in temporalio/temporal.","triggerScenarios":"Thrown at common/persistence/query_util.go:182 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}