{"record":{"id":"480a15ad212ddab4","repo":"gastownhall/beads","slug":"failed-to-parse-dsn-for-long-timeout-connection","errorCode":null,"errorMessage":"failed to parse DSN for long-timeout connection: %w","messagePattern":"failed to parse DSN for long-timeout connection: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/store.go","lineNumber":2240,"sourceCode":"// readTimeout when the server performs network I/O to git remotes.\n//\n// The query is wrapped in an explicit transaction (BEGIN/COMMIT) so that\n// DOLT_PULL merge operations succeed even when the server runs with\n// autocommit=1. Without this, Dolt rejects merges under autocommit because\n// it cannot expose conflict-resolution tables to the caller.\n//\n// Audited for be-b0am's fresh-connection branch hazard: safe — but the two\n// callers are safe for different reasons, so the annotation names both.\n// federation.go's CALL DOLT_PUSH(?, ?) names the refspec explicitly. Its\n// CALL DOLT_FETCH(?) passes only the remote: with no refspec argument dolt\n// falls back to the remote's configured refspecs (ParseRefSpecs ->\n// GetRefSpecs), which are remote config rather than session state, and a\n// fetch writes only remote-tracking refs, never the working branch. Neither\n// depends on this fresh connection's default checkout.\nfunc (s *DoltStore) execWithLongTimeout(ctx context.Context, query string, args ...any) error {\n\tcfg, err := mysql.ParseDSN(s.connStr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to parse DSN for long-timeout connection: %w\", err)\n\t}\n\tcfg.ReadTimeout = 5 * time.Minute\n\tdb, err := sql.Open(\"mysql\", cfg.FormatDSN())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open long-timeout connection: %w\", err)\n\t}\n\tdefer db.Close()\n\tdb.SetMaxOpenConns(1)\n\ttx, err := db.BeginTx(ctx, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to begin transaction: %w\", err)\n\t}\n\tif _, err := tx.ExecContext(ctx, query, args...); err != nil {\n\t\t_ = tx.Rollback()\n\t\treturn err\n\t}\n\treturn tx.Commit()\n}","sourceCodeStart":2222,"sourceCodeEnd":2258,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/store.go#L2222-L2258","documentation":"execWithLongTimeout re-parses the store's connection string with go-sql-driver/mysql.ParseDSN to build a dedicated 5-minute-read-timeout connection. This error wraps a DSN parse failure, meaning the stored connStr is malformed for the mysql driver.","triggerScenarios":"Calling execWithLongTimeout when s.connStr cannot be parsed by mysql.ParseDSN — e.g. invalid URL format, unescaped special characters in password, or bad parameters.","commonSituations":"Password contains characters needing DSN escaping; manually edited config producing an invalid DSN; buildServerDSN producing a scheme mismatch (http vs tcp).","solutions":["Inspect the DSN in bd dolt status / config and fix malformed parts","Re-run bd init or restart bd dolt server to regenerate the DSN","Escape or URL-encode special characters in the password","Verify connection settings in .beads/metadata.json"],"exampleFix":"// before\nconnStr := \"user:p@ss!w0rd@tcp(localhost:3307)/db\"\n// after\nconnStr := \"user:p%40ss%21w0rd@tcp(localhost:3307)/db\"","handlingStrategy":"validation","validationCode":"if _, err := mysql.ParseDSN(connStr); err != nil {\n    return fmt.Errorf(\"invalid DSN before long query: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := store.execWithLongTimeout(ctx, q)\nif err != nil {\n    var ue *mysql.MySQLError\n    if strings.Contains(err.Error(), \"failed to parse DSN\") {\n        // regenerate connStr\n    }\n    return err\n}","preventionTips":["URL-encode special chars in DSN credentials","Never hand-edit generated connection strings","Validate DSNs at config load time","Test DSN round-trip with ParseDSN/FormatDSN"],"tags":["configuration","dsn","mysql","parsing"],"backgroundTag":"invalid-dsn","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}