{"record":{"id":"e1009e8bc167c9b5","repo":"golang-migrate/migrate","slug":"no-config-e1009e","errorCode":null,"errorMessage":"no config","messagePattern":"no config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/neo4j/neo4j.go","lineNumber":30,"sourceCode":"\t\"github.com/golang-migrate/migrate/v4/database\"\n\t\"github.com/golang-migrate/migrate/v4/database/multistmt\"\n\t\"github.com/neo4j/neo4j-go-driver/neo4j\"\n)\n\nfunc init() {\n\tdb := Neo4j{}\n\tdatabase.Register(\"neo4j\", &db)\n}\n\nconst DefaultMigrationsLabel = \"SchemaMigration\"\n\nvar (\n\tStatementSeparator           = []byte(\";\")\n\tDefaultMultiStatementMaxSize = 10 * 1 << 20 // 10 MB\n)\n\nvar (\n\tErrNilConfig = fmt.Errorf(\"no config\")\n)\n\ntype Config struct {\n\tMigrationsLabel       string\n\tMultiStatement        bool\n\tMultiStatementMaxSize int\n}\n\ntype Neo4j struct {\n\tdriver neo4j.Driver\n\tlock   uint32\n\n\t// Open and WithInstance need to guarantee that config is never nil\n\tconfig *Config\n}\n\nfunc WithInstance(driver neo4j.Driver, config *Config) (database.Driver, error) {\n\tif config == nil {","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/neo4j/neo4j.go#L12-L48","documentation":"ErrNilConfig is the Neo4j driver's sentinel meaning WithInstance/WithConnection was called with a nil *Config. These constructors dereference the config immediately (e.g. reading MigrationsLabel, MultiStatementMaxSize), so the library fails fast with this error instead of panicking. It is raised at database/neo4j/neo4j.go:30 and equivalent sentinels exist in cassandra/pgx/mysql drivers.","triggerScenarios":"Calling neo4j.WithInstance(driver, nil) or neo4j.WithConnection(session, nil); passing a Config variable that was declared but never initialized, or one that a factory function returned as nil on an error path that was ignored.","commonSituations":"Constructing the driver in a helper where the config is built conditionally; ignoring an earlier error so the *Config is still nil; refactoring that changed Config from value to pointer semantics.","solutions":["Pass a non-nil &neo4j.Config{} (fields may be left at defaults) to WithInstance/WithConnection","Check the error from whatever function builds your Config before using it","In code that receives a *Config, guard with if cfg == nil before calling the driver"],"exampleFix":"// before\ndrv, err := neo4j.WithInstance(driver, nil)\n// after\ncfg := &neo4j.Config{ MigrationsLabel: \"migration\" }\ndrv, err := neo4j.WithInstance(driver, cfg)","handlingStrategy":"validation","validationCode":"func validateNeo4jConfig(cfg *neo4j.Config) error {\n    if cfg == nil {\n        return errors.New(\"neo4j config must not be nil\")\n    }\n    return nil\n}","typeGuard":"func hasNeo4jConfig(cfg *neo4j.Config) bool { return cfg != nil }","tryCatchPattern":"drv, err := neo4j.WithInstance(driver, cfg)\nif errors.Is(err, neo4j.ErrNilConfig) {\n    return fmt.Errorf(\"neo4j: config was nil, check config construction: %w\", err)\n}","preventionTips":["Always construct Config with &neo4j.Config{...}, never assign nil","Check errors from config-building helpers before using their result","Guard with a nil check at the wiring boundary where the driver is created"],"tags":["neo4j","configuration","nil-check","driver-init"],"backgroundTag":"nil-config","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}