{"record":{"id":"6c877a1a18702023","repo":"AlistGo/alist","slug":"api-key-is-required","errorCode":null,"errorMessage":"API key is required","messagePattern":"API key is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/darkibox/driver.go","lineNumber":32,"sourceCode":"\t\"github.com/alist-org/alist/v3/internal/op\"\n)\n\ntype Darkibox struct {\n\tmodel.Storage\n\tAddition\n}\n\nfunc (d *Darkibox) Config() driver.Config {\n\treturn config\n}\n\nfunc (d *Darkibox) GetAddition() driver.Additional {\n\treturn &d.Addition\n}\n\nfunc (d *Darkibox) Init(ctx context.Context) error {\n\tif d.APIKey == \"\" {\n\t\treturn fmt.Errorf(\"API key is required\")\n\t}\n\tif d.RootFolderID == \"\" {\n\t\td.RootFolderID = \"0\"\n\t}\n\n\t// Verify API key by calling account/info\n\tvar account accountInfoResult\n\tif err := d.callAPI(ctx, \"/account/info\", nil, &account); err != nil {\n\t\treturn fmt.Errorf(\"failed to verify API key: %w\", err)\n\t}\n\n\top.MustSaveDriverStorage(d)\n\treturn nil\n}\n\nfunc (d *Darkibox) Drop(ctx context.Context) error {\n\treturn nil\n}","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/darkibox/driver.go#L14-L50","documentation":"Returned by Darkibox.Init when the Addition's APIKey field is empty. The Darkibox driver authenticates every request by injecting the key as a query parameter (callAPI adds ?key=...), so an empty key cannot work; Init fails fast before any network call rather than producing confusing 401s later. Storage cannot be added until a key is supplied.","triggerScenarios":"Adding a Darkibox storage in the AList admin UI with the API key field left blank; programmatically creating the storage with an empty addition; the key field name changing between versions so the submitted value lands in the wrong field.","commonSituations":"Forgetting to fill the api_key field; copy-pasting into the wrong field; automation scripts omitting the key; schema changes after driver upgrades dropping the stored key.","solutions":["Fill in the Darkibox API key in the storage addition settings and save","Get the key from your Darkibox account page (account/API section) and paste it exactly, without surrounding whitespace","If set via API/automation, ensure the addition JSON includes a non-empty api_key field","Verify after saving that Init succeeds (storage shows as working)"],"exampleFix":"// before\n{\"driver\":\"darkibox\",\"addition\":{\"api_key\":\"\"}}\n// after\n{\"driver\":\"darkibox\",\"addition\":{\"api_key\":\"YOUR_DARKIBOX_KEY\"}}","handlingStrategy":"validation","validationCode":"// Before adding the storage, assert a non-empty key\nif strings.TrimSpace(addition.APIKey) == \"\" {\n    return errors.New(\"api_key is required for darkibox storage\")\n}","typeGuard":"func hasDarkiboxKey(a Addition) bool {\n    return strings.TrimSpace(a.APIKey) != \"\"\n}","tryCatchPattern":"if err := d.Init(ctx); err != nil {\n    if err.Error() == \"API key is required\" {\n        // config omission: collect the key and re-save; no retry helps\n        return errors.New(\"set the Darkibox API key in storage settings\")\n    }\n    return err\n}","preventionTips":["Make API key a required field in provisioning automation (fail the form/script on empty)","Copy the key directly from the Darkibox account page; avoid whitespace","After adding, confirm storage status shows work to validate the whole chain"],"tags":["darkibox","config","api-key","initialization"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}