{"record":{"id":"8572eae31727b3dd","repo":"golang-migrate/migrate","slug":"unable-to-parse-option-x-migrations-table-quoted-8572ea","errorCode":null,"errorMessage":"unable to parse option x-migrations-table-quoted: %w","messagePattern":"unable to parse option x-migrations-table-quoted: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/postgres/postgres.go","lineNumber":168,"sourceCode":"}\n\nfunc (p *Postgres) Open(url string) (database.Driver, error) {\n\tpurl, err := nurl.Parse(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdb, err := sql.Open(\"postgres\", migrate.FilterCustomQuery(purl).String())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tmigrationsTable := purl.Query().Get(\"x-migrations-table\")\n\tmigrationsTableQuoted := false\n\tif s := purl.Query().Get(\"x-migrations-table-quoted\"); len(s) > 0 {\n\t\tmigrationsTableQuoted, err = strconv.ParseBool(s)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to parse option x-migrations-table-quoted: %w\", err)\n\t\t}\n\t}\n\tif (len(migrationsTable) > 0) && (migrationsTableQuoted) && ((migrationsTable[0] != '\"') || (migrationsTable[len(migrationsTable)-1] != '\"')) {\n\t\treturn nil, fmt.Errorf(\"x-migrations-table must be quoted (for instance '\\\"migrate\\\".\\\"schema_migrations\\\"') when x-migrations-table-quoted is enabled, current value is: %s\", migrationsTable)\n\t}\n\n\tstatementTimeoutString := purl.Query().Get(\"x-statement-timeout\")\n\tstatementTimeout := 0\n\tif statementTimeoutString != \"\" {\n\t\tstatementTimeout, err = strconv.Atoi(statementTimeoutString)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tmultiStatementMaxSize := DefaultMultiStatementMaxSize\n\tif s := purl.Query().Get(\"x-multi-statement-max-size\"); len(s) > 0 {\n\t\tmultiStatementMaxSize, err = strconv.Atoi(s)","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/postgres/postgres.go#L150-L186","documentation":"Same validation as the pgx/v5 driver but in database/postgres (lib/pq path): Open parses the x-migrations-table-quoted URL option with strconv.ParseBool and wraps any parse failure with this message. The migration never reaches the database.","triggerScenarios":"postgres.Open (or the registered database/sql driver 'postgres' via sql.Open + migrate) with a URL like postgres://u:p@host/db?x-migrations-table-quoted=enabled or containing whitespace in the value.","commonSituations":"Hand-editing DSN strings, config templates emitting 'True' with trailing spaces or 'yes', mixing up this option with another library's boolean syntax, URL-encoding issues leaving %20 in the value.","solutions":["Set the option to a ParseBool-valid literal: true, false, 1, 0, t, f, T, F, TRUE, FALSE, True, False","Remove the parameter to accept the default (false)","Percent-encode or single-quote the DSN so no spaces/invalid characters sneak into the value","Confirm with the wrapped strconv error which raw string was rejected"],"exampleFix":"// before\ndsn := \"postgres://u:p@host/db?x-migrations-table-quoted=enabled\"\n// after\ndsn := \"postgres://u:p@host/db?x-migrations-table-quoted=true\"","handlingStrategy":"validation","validationCode":"u, _ := url.Parse(dsn)\nif v := u.Query().Get(\"x-migrations-table-quoted\"); v != \"\" {\n    if _, err := strconv.ParseBool(v); err != nil {\n        return fmt.Errorf(\"invalid x-migrations-table-quoted %q: %w\", v, err)\n    }\n}","typeGuard":"func isParseBoolValue(v string) bool {\n    _, err := strconv.ParseBool(v)\n    return err == nil\n}","tryCatchPattern":"if err := openMigrations(); err != nil {\n    if strings.Contains(err.Error(), \"unable to parse option x-migrations-table-quoted\") {\n        log.Fatalf(\"use true/false (or 1/0) for x-migrations-table-quoted: %v\", err)\n    }\n    panic(err)\n}","preventionTips":["Restrict DSN booleans to Go's ParseBool literals","Trim and sanitize DSN strings sourced from env vars/config files","Add a startup check that parses all x-* query options before migrate.Open"],"tags":["configuration","url-parameters","postgres","parsing"],"backgroundTag":"invalid-url-option-value","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}