{"record":{"id":"0ec8d75e59319d46","repo":"gofr-dev/gofr","slug":"both-username-and-password-must-be-provided","errorCode":null,"errorMessage":"both username and password must be provided","messagePattern":"both username and password must be provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/datasource/surrealdb/surrealdb.go","lineNumber":20,"sourceCode":"\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"math\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/surrealdb/surrealdb.go\"\n\t\"github.com/surrealdb/surrealdb.go/pkg/models\"\n\t\"go.opentelemetry.io/otel/attribute\"\n\t\"go.opentelemetry.io/otel/trace\"\n)\n\nvar (\n\terrNotConnected             = errors.New(\"not connected to database\")\n\terrNoDatabaseInstance       = errors.New(\"failed to connect to SurrealDB: no valid database instance\")\n\terrInvalidCredentialsConfig = errors.New(\"both username and password must be provided\")\n\terrNoRecord                 = errors.New(\"no record found\")\n\terrNoResult                 = errors.New(\"no result found in query response\")\n\terrUnexpectedResult         = errors.New(\"unexpected result type: expected []any\")\n\terrQueryError               = errors.New(\"query error\")\n)\n\nconst (\n\tschemeHTTP      = \"http\"\n\tschemeHTTPS     = \"https\"\n\tschemeWS        = \"ws\"\n\tschemeWSS       = \"wss\"\n\tschemeMemory    = \"memory\"\n\tschemeMem       = \"mem\"\n\tschemeSurrealkv = \"surrealkv\"\n\tstatusOK        = \"OK\"\n\n\tdefaultTimeout = 30 * time.Second\n)","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/datasource/surrealdb/surrealdb.go#L2-L38","documentation":"errInvalidCredentialsConfig is returned by authenticateCredentials when SurrealDB authentication is attempted without both a username and a password present in the configuration. gofr treats partial credentials as a configuration defect and refuses to authenticate.","triggerScenarios":"Connect/authenticate flow where only one of SURREALDB_USER / SURREALDB_PASS (or equivalent config fields) is set, or both are empty while authentication is required.","commonSituations":"Missing env var in one deployment environment, secret not mounted so the password env is empty, typo in the env var name, or a config struct where only the user field was populated.","solutions":["Set both username and password env/config values (e.g. SURREALDB_USER and SURREALDB_PASS).","Verify the secret containing credentials is actually mounted and non-empty in the container.","Check for env var name typos and that the values aren't blank strings."],"exampleFix":"// before\nSURREALDB_USER=root\nSURREALDB_PASS=            # empty\n// after\nSURREALDB_USER=root\nSURREALDB_PASS=secret123","handlingStrategy":"validation","validationCode":"user, pass := os.Getenv(\"SURREALDB_USER\"), os.Getenv(\"SURREALDB_PASS\")\nif user == \"\" || pass == \"\" {\n    return errors.New(\"both SURREALDB_USER and SURREALDB_PASS must be set\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail fast at startup when required credential env vars are empty.","Verify secret mounts contain both keys in every environment.","Use a config linter that checks required env vars before boot."],"tags":["surrealdb","authentication","configuration"],"backgroundTag":"missing-credentials","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}