{"record":{"id":"5fb087ce8da73e92","repo":"golang-migrate/migrate","slug":"both-x-advisory-lock-timeout-interval-and-x-adviso","errorCode":null,"errorMessage":"both x-advisory-lock-timeout-interval and x-advisory-lock-timout-interval were specified","messagePattern":"both x-advisory-lock-timeout-interval and x-advisory-lock-timout-interval were specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/mongodb/mongodb.go","lineNumber":41,"sourceCode":"\tdb := Mongo{}\n\tdatabase.Register(\"mongodb\", &db)\n\tdatabase.Register(\"mongodb+srv\", &db)\n}\n\nvar DefaultMigrationsCollection = \"schema_migrations\"\n\nconst DefaultLockingCollection = \"migrate_advisory_lock\" // the collection to use for advisory locking by default.\nconst lockKeyUniqueValue = 0                             // the unique value to lock on. If multiple clients try to insert the same key, it will fail (locked).\nconst DefaultLockTimeout = 15                            // the default maximum time to wait for a lock to be released.\nconst DefaultLockTimeoutInterval = 10                    // the default maximum intervals time for the locking timout.\nconst DefaultAdvisoryLockingFlag = true                  // the default value for the advisory locking feature flag. Default is true.\nconst LockIndexName = \"lock_unique_key\"                  // the name of the index which adds unique constraint to the locking_key field.\nconst contextWaitTimeout = 5 * time.Second               // how long to wait for the request to mongo to block/wait for.\n\nvar (\n\tErrNoDatabaseName            = fmt.Errorf(\"no database name\")\n\tErrNilConfig                 = fmt.Errorf(\"no config\")\n\tErrLockTimeoutConfigConflict = fmt.Errorf(\"both x-advisory-lock-timeout-interval and x-advisory-lock-timout-interval were specified\")\n)\n\ntype Mongo struct {\n\tclient   *mongo.Client\n\tdb       *mongo.Database\n\tconfig   *Config\n\tisLocked atomic.Bool\n}\n\ntype Locking struct {\n\tCollectionName string\n\tTimeout        int\n\tEnabled        bool\n\tInterval       int\n}\ntype Config struct {\n\tDatabaseName         string\n\tMigrationsCollection string","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/mongodb/mongodb.go#L23-L59","documentation":"ErrLockTimeoutConfigConflict is returned by mongodb.Open when the connection URL contains both the canonical x-advisory-lock-timeout-interval parameter and the misspelled legacy alias x-advisory-lock-timout-interval. The driver refuses to guess which timeout to use, so Open fails fast. Using only one of the two is accepted (the typo is kept for backwards compatibility).","triggerScenarios":"A MongoDB DSN with both x-advisory-lock-timeout-interval and x-advisory-lock-timout-interval query parameters, e.g. after someone 'fixed' part of the name while an old copy still contained the typo.","commonSituations":"Merging config from two sources (env var + config file) where one predates the spelling fix; copy-pasting DSNs from old documentation that used the misspelled key.","solutions":["Remove the misspelled x-advisory-lock-timout-interval parameter from the URL","Keep only x-advisory-lock-timeout-interval (the correctly spelled key)","Audit all DSN sources (env, config files, secrets) for duplicate lock-timeout keys"],"exampleFix":"// before\nmongodb://localhost:27017/mydb?x-advisory-lock-timeout-interval=30&x-advisory-lock-timout-interval=30\n// after\nmongodb://localhost:27017/mydb?x-advisory-lock-timeout-interval=30","handlingStrategy":"validation","validationCode":"u, _ := url.Parse(dsn)\nq := u.Query()\nif q.Get(\"x-advisory-lock-timeout-interval\") != \"\" && q.Get(\"x-advisory-lock-timout-interval\") != \"\" {\n    return fmt.Errorf(\"remove duplicate/misspelled x-advisory-lock-timout-interval from DSN\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if errors.Is(err, mongodb.ErrLockTimeoutConfigConflict) {\n        return fmt.Errorf(\"DSN specifies lock timeout twice (typo key still present)\")\n    }\n    return err\n}","preventionTips":["Standardize on x-advisory-lock-timeout-interval in all environments","Grep config/secrets repos for the misspelled x-advisory-lock-timout-interval","Keep the canonical DSN in one templated source, not per-env copies"],"tags":["go","golang-migrate","mongodb","config","query-params","conflict"],"backgroundTag":"duplicate-config-parameter","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}