{"record":{"id":"f077311087aa366d","repo":"router-for-me/CLIProxyAPI","slug":"invalid-auth-weight-w","errorCode":null,"errorMessage":"invalid auth weight: %w","messagePattern":"invalid auth weight: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pluginhost/auth_callbacks.go","lineNumber":355,"sourceCode":"\t\tStatus:   coreauth.StatusActive,\n\t\tAttributes: map[string]string{\n\t\t\t\"path\":   path,\n\t\t\t\"source\": path,\n\t\t},\n\t\tMetadata:  metadata,\n\t\tCreatedAt: time.Now().UTC(),\n\t\tUpdatedAt: time.Now().UTC(),\n\t}\n\tif manager := h.currentAuthManager(); manager != nil {\n\t\tif existing, ok := manager.GetByID(authID); ok {\n\t\t\tauth.CreatedAt = existing.CreatedAt\n\t\t\tauth.LastRefreshedAt = existing.LastRefreshedAt\n\t\t\tauth.NextRetryAfter = existing.NextRetryAfter\n\t\t\tauth.Runtime = existing.Runtime\n\t\t}\n\t}\n\tif errWeight := coreauth.ValidateAuthWeight(auth); errWeight != nil {\n\t\treturn nil, fmt.Errorf(\"invalid auth weight: %w\", errWeight)\n\t}\n\tcoreauth.ApplyCustomHeadersFromMetadata(auth)\n\treturn auth, nil\n}\n\nfunc (h *Host) upsertAuthRecord(ctx context.Context, auth *coreauth.Auth) error {\n\tmanager := h.currentAuthManager()\n\tif manager == nil || auth == nil {\n\t\treturn nil\n\t}\n\tif existing, ok := manager.GetByID(auth.ID); ok {\n\t\tauth.CreatedAt = existing.CreatedAt\n\t\t_, errUpdate := manager.Update(ctx, auth)\n\t\treturn errUpdate\n\t}\n\t_, errRegister := manager.Register(ctx, auth)\n\treturn errRegister\n}","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/pluginhost/auth_callbacks.go#L337-L373","documentation":"Wrapped error from coreauth.ValidateAuthWeight inside Host.buildAuthFromFileData. Auth metadata may carry a weight field controlling round-robin distribution; a weight that fails validation (wrong type, out of allowed range, negative) aborts the build before the record is used.","triggerScenarios":"Auth file or plugin-supplied AuthData contains an invalid 'weight' value — e.g. a string, zero/negative number, or a value beyond the accepted maximum defined by coreauth.","commonSituations":"Hand-edited auth file adding a weight key with a bad format; plugin emitting weight as string; older file written before weight rules tightened by a version upgrade.","solutions":["Inspect the wrapped message for the exact weight rule violated","Fix or remove the weight field in the auth file (fall back to the default) and retry","After upgrading, re-validate existing auth files against the new weight constraints"],"exampleFix":"// before\n{\"type\": \"gemini\", \"weight\": \"high\"}\n\n// after\n{\"type\": \"gemini\", \"weight\": 3}","handlingStrategy":"validation","validationCode":"// before saving, mirror the host check:\nif w, ok := metadata[\"weight\"]; ok {\n    if _, ok := w.(float64); !ok {\n        // remove or fix the weight field before saving\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"invalid auth weight\") {\n    // strip weight from the file to fall back to default and retry\n}","preventionTips":["Keep weight as a number within the documented range or omit it","Re-validate auth files after upgrading the proxy"],"tags":["go","pluginhost","auth","validation","load-balancing"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}