{"record":{"id":"bc202f8733ddb2f1","repo":"vxcontrol/pentagi","slug":"failed-to-insert-resource-q-w","errorCode":null,"errorMessage":"failed to insert resource %q: %w","messagePattern":"failed to insert resource %q: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"backend/pkg/server/services/resources.go","lineNumber":413,"sourceCode":"\tvar createdDirs []models.UserResource\n\tvar txErr error\n\tif dirPath != \"\" {\n\t\tcreatedDirs, _, _, txErr = ensureResourceDirs(tx, uid, dirPath, false)\n\t}\n\tfor _, p := range pendingList {\n\t\tif txErr != nil {\n\t\t\tbreak\n\t\t}\n\t\trec := models.UserResource{\n\t\t\tUserID: uid,\n\t\t\tHash:   p.hash,\n\t\t\tName:   p.name,\n\t\t\tPath:   p.vPath,\n\t\t\tSize:   p.size,\n\t\t\tIsDir:  false,\n\t\t}\n\t\tif err := tx.Create(&rec).Error; err != nil {\n\t\t\ttxErr = fmt.Errorf(\"failed to insert resource %q: %w\", p.vPath, err)\n\t\t\tbreak\n\t\t}\n\t\tsaved = append(saved, rec)\n\t}\n\n\tif txErr != nil {\n\t\ttx.Rollback()\n\t\tfor _, p := range pendingList {\n\t\t\tif p.newBlob {\n\t\t\t\ts.deleteOrphanBlob(context.Background(), p.hash)\n\t\t\t}\n\t\t}\n\t\tif isUniqueViolation(txErr) {\n\t\t\tresponse.Error(c, response.ErrResourcesAlreadyExists, txErr)\n\t\t} else if errors.Is(txErr, errResourceConflict) {\n\t\t\tresponse.Error(c, response.ErrResourcesAlreadyExists, txErr)\n\t\t} else {\n\t\t\tlogger.FromContext(c).WithError(txErr).Error(\"failed to persist uploaded resources\")","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/server/services/resources.go#L395-L431","documentation":"Error \"failed to insert resource %q: %w\" thrown in vxcontrol/pentagi.","triggerScenarios":"Thrown at backend/pkg/server/services/resources.go:413 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}