{"record":{"id":"3c7ac718344b92cf","repo":"golang-migrate/migrate","slug":"failed-to-parse-consistency-s-v","errorCode":null,"errorMessage":"failed to parse consistency \"%s\": %v","messagePattern":"failed to parse consistency \"(.+?)\": (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/cassandra/cassandra.go","lineNumber":339,"sourceCode":"\terr = c.session.Query(fmt.Sprintf(\"CREATE TABLE IF NOT EXISTS %s (version bigint, dirty boolean, PRIMARY KEY(version))\", c.config.MigrationsTable)).Exec()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif _, _, err = c.Version(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// ParseConsistency wraps gocql.ParseConsistency\n// to return an error instead of a panicking.\nfunc parseConsistency(consistencyStr string) (consistency gocql.Consistency, err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tvar ok bool\n\t\t\terr, ok = r.(error)\n\t\t\tif !ok {\n\t\t\t\terr = fmt.Errorf(\"failed to parse consistency \\\"%s\\\": %v\", consistencyStr, r)\n\t\t\t}\n\t\t}\n\t}()\n\tconsistency = gocql.ParseConsistency(consistencyStr)\n\n\treturn consistency, nil\n}\n","sourceCodeStart":321,"sourceCodeEnd":347,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/cassandra/cassandra.go#L321-L347","documentation":"In the Cassandra driver, parseConsistency wraps gocql.ParseConsistency. ParseConsistency panics for an unrecognized consistency string; the deferred recover converts that panic into an error. If the recovered value is not an error, the string \"failed to parse consistency \\\"%s\\\": %v\" is produced, embedding the offending input and the panic value.","triggerScenarios":"Passing an invalid x-consistency query parameter or Config consistency value (e.g. \"quorom\" misspelling, \"foo\") that gocql.ParseConsistency panics on with a non-error panic value.","commonSituations":"Typo in the consistency level in the Cassandra DSN query string; case/spacing mistakes; using a consistency level from a different driver's naming convention.","solutions":["Correct the consistency string to a valid gocql level: any, one, two, three, quorum, all, local_quorum, each_quorum, local_one.","Check the x-consistency query parameter in the Cassandra URL for typos and exact spelling.","Validate the consistency string against gocql.ParseConsistency in a recover-safe wrapper before building the cluster config."],"exampleFix":"// before\ndsn := \"cassandra://host:9042/keyspace?x-consistency=quorom\"\n// after\ndsn := \"cassandra://host:9042/keyspace?x-consistency=quorum\"","handlingStrategy":"validation","validationCode":"validConsistencies := map[string]bool{\n    \"any\": true, \"one\": true, \"two\": true, \"three\": true, \"quorum\": true,\n    \"all\": true, \"local_quorum\": true, \"each_quorum\": true, \"local_one\": true,\n}\nif !validConsistencies[strings.ToLower(consistency)] {\n    return fmt.Errorf(\"invalid consistency %q\", consistency)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to parse consistency\") {\n    return fmt.Errorf(\"check the x-consistency parameter in your Cassandra URL: %w\", err)\n}","preventionTips":["Spell consistency levels exactly as gocql expects (e.g. local_quorum, not localquorum).","Keep the consistency value in one validated config constant, not ad-hoc strings.","Unit-test DSN parsing with the exact URLs used in each environment."],"tags":["cassandra","configuration","parsing"],"backgroundTag":"invalid-config-value","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}