{"record":{"id":"ed6c67fd31337850","repo":"gofr-dev/gofr","slug":"no-record-found","errorCode":null,"errorMessage":"no record found","messagePattern":"no record found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/datasource/surrealdb/surrealdb.go","lineNumber":21,"sourceCode":"import (\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)\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/datasource/surrealdb/surrealdb.go#L3-L39","documentation":"errNoRecord is returned by Create and Update on the SurrealDB client when the operation completes but the response contains no record — gofr expected the created/updated document back from SurrealDB and got an empty result. It indicates the write did not produce a returned record.","triggerScenarios":"Calling client.Create with a table/ID whose insert yields no stored document, or client.Update targeting a record ID that does not exist (SurrealDB returns no result for a missing record on update).","commonSituations":"Updating a record that was deleted by another writer, wrong record ID format (missing table prefix in the ID), permissions preventing the write so nothing is stored, or table-level rules dropping the insert.","solutions":["Verify the record ID/table exists before Update (query it first) and that Create uses a valid table name.","Check SurrealDB permissions/auth allow the write for the connected user.","Confirm the record ID format is correct (e.g. table:id via models.RecordID).","Inspect the SurrealDB response/logs to see why no record was returned."],"exampleFix":"// before\n_, err := client.Update(ctx, \"user:999\", data) // record never existed\n// after\nrec, err := client.Create(ctx, \"user\", data)\n// then update using the returned record's ID","handlingStrategy":"try-catch","validationCode":"existing, qerr := client.Query(ctx, \"SELECT * FROM user:999\")\nif qerr != nil && !errors.Is(qerr, surrealdb.ErrNoResult) { return qerr }","typeGuard":null,"tryCatchPattern":"rec, err := client.Update(ctx, id, data)\nif errors.Is(err, surrealdb.ErrNoRecord) {\n    return fmt.Errorf(\"record %s does not exist: %w\", id, err)\n}","preventionTips":["Create records before updating; use the ID returned by Create.","Use correct record ID format (table:id).","Grant SurrealDB write permissions to the connected user/role."],"tags":["surrealdb","crud","not-found"],"backgroundTag":"record-not-found","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}