{"record":{"id":"3b9281501e02a994","repo":"glanceapp/glance","slug":"computing-username-hash-for-user-s-v","errorCode":null,"errorMessage":"computing username hash for user %s: %v","messagePattern":"computing username hash for user (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/glance.go","lineNumber":79,"sourceCode":"\tif len(config.Auth.Users) > 0 {\n\t\tsecretBytes, err := base64.StdEncoding.DecodeString(config.Auth.SecretKey)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"decoding secret-key: %v\", err)\n\t\t}\n\n\t\tif len(secretBytes) != AUTH_SECRET_KEY_LENGTH {\n\t\t\treturn nil, fmt.Errorf(\"secret-key must be exactly %d bytes\", AUTH_SECRET_KEY_LENGTH)\n\t\t}\n\n\t\tapp.usernameHashToUsername = make(map[string]string)\n\t\tapp.failedAuthAttempts = make(map[string]*failedAuthAttempt)\n\t\tapp.RequiresAuth = true\n\n\t\tfor username := range config.Auth.Users {\n\t\t\tuser := config.Auth.Users[username]\n\t\t\tusernameHash, err := computeUsernameHash(username, secretBytes)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"computing username hash for user %s: %v\", username, err)\n\t\t\t}\n\t\t\tapp.usernameHashToUsername[string(usernameHash)] = username\n\n\t\t\tif user.PasswordHashString != \"\" {\n\t\t\t\tuser.PasswordHash = []byte(user.PasswordHashString)\n\t\t\t\tuser.PasswordHashString = \"\"\n\t\t\t} else {\n\t\t\t\thashedPassword, err := bcrypt.GenerateFromPassword([]byte(user.Password), bcrypt.DefaultCost)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"hashing password for user %s: %v\", username, err)\n\t\t\t\t}\n\n\t\t\t\tuser.Password = \"\"\n\t\t\t\tuser.PasswordHash = hashedPassword\n\t\t\t}\n\t\t}\n\n\t\tapp.authSecretKey = secretBytes","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/glance.go#L61-L97","documentation":"Returned when computeUsernameHash() fails for a configured user during startup. That function builds an HMAC-SHA256 over the username using the second half of the secret key; the only realistic failure is a hashing primitive failure (e.g. hmac.Write error), which is practically unreachable with sha256. Seeing it usually indicates memory/hardware corruption or a non-standard build.","triggerScenarios":"computeUsernameHash returning a non-nil error while iterating config.Auth.Users during newApplication(). Standard library sha256/HMAC essentially never errors here.","commonSituations":"Essentially never seen in practice; would surface only under extreme conditions (corrupted runtime, patched crypto stack). If it appears, suspect a modified glance build or failing hardware.","solutions":["Rebuild/reinstall glance from a clean source tree to rule out a patched crypto stack","Re-run startup; a transient occurrence points to memory/hardware diagnostics rather than config","Report upstream with full environment details if it reproduces on an unmodified build"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Wrap newApplication(); if the chained error names computeUsernameHash, treat as environment/build corruption: log environment details and exit rather than retry — retrying identical input is noise.","preventionTips":["Use official builds or clean source builds","Avoid patched crypto libraries in the runtime image","Monitor for other signs of memory corruption if this appears"],"tags":["auth","crypto","startup"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}