{"record":{"id":"fa9436bc19596ec2","repo":"AlistGo/alist","slug":"check-share-id-availability-w","errorCode":null,"errorMessage":"check share id availability: %w","messagePattern":"check share id availability: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/handles/share.go","lineNumber":233,"sourceCode":"\t}\n\treturn nil\n}\n\nfunc resolveRequestedShareID(rawShareID, fallback string, excludeID uint) (string, error) {\n\tshareID := strings.TrimSpace(rawShareID)\n\tif shareID == \"\" {\n\t\tif fallback != \"\" {\n\t\t\treturn fallback, nil\n\t\t}\n\t\treturn generateShareID()\n\t}\n\tif err := validateCustomShareID(shareID); err != nil {\n\t\treturn \"\", err\n\t}\n\tif excludeID == 0 {\n\t\texists, err := db.ShareIDExists(shareID)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"check share id availability: %w\", err)\n\t\t}\n\t\tif exists {\n\t\t\treturn \"\", errShareIDExists\n\t\t}\n\t\treturn shareID, nil\n\t}\n\texists, err := db.ShareIDExistsExceptID(shareID, excludeID)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"check share id availability: %w\", err)\n\t}\n\tif exists {\n\t\treturn \"\", errShareIDExists\n\t}\n\treturn shareID, nil\n}\n\nfunc normalizeShareAccessLimit(accessLimit int64, burnAfterRead *bool) (int64, bool, error) {\n\tif accessLimit < 0 {","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/server/handles/share.go#L215-L251","documentation":"While resolving a share ID for creation (excludeID == 0 path), the database uniqueness check db.ShareIDExists(shareID) itself returned an error; it is wrapped as 'check share id availability: %w'. This is a data-layer failure, not a duplicate-ID conflict (that returns errShareIDExists instead).","triggerScenarios":"Creating a share while the database is unreachable, the x_shares table is locked/corrupt, or the DB connection pool is exhausted.","commonSituations":"Database downtime or restart during share creation; SQLite lock contention under concurrent writes; migration leaving the shares table in a bad state.","solutions":["Inspect the wrapped error for the DB root cause (connection refused, lock timeout, etc.)","Restore DB connectivity and retry the request","For SQLite, reduce concurrent write traffic or move to a client-server DB","Verify the schema is migrated (x_shares table and columns exist)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if err := db.Ping(); err != nil {\n    return fmt.Errorf(\"db unavailable, deferring share creation: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := resolveShareID(req.ShareID, \"\", 0); err != nil {\n    if strings.Contains(err.Error(), \"check share id availability\") {\n        // data-layer failure: check DB health, then retry; do not tell the user the ID is taken\n    }\n}","preventionTips":["Monitor DB connectivity in health checks","Avoid SQLite write concurrency storms during share creation","Keep migrations applied so ShareIDExists queries never fail structurally"],"tags":["go","share","database","api"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}