{"record":{"id":"e676d1f4c1d2118e","repo":"router-for-me/CLIProxyAPI","slug":"openai-compatibility-d-api-key-entries-d-weigh","errorCode":null,"errorMessage":"openai-compatibility[%d].api-key-entries[%d].weight: %w","messagePattern":"openai-compatibility\\[(.+?)\\]\\.api-key-entries\\[(.+?)\\]\\.weight: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/weight.go","lineNumber":148,"sourceCode":"\t\tif errValidate := ValidateCredentialWeight(cfg.VertexCompatAPIKey[index].Weight); errValidate != nil {\n\t\t\treturn fmt.Errorf(\"vertex-api-key[%d].weight: %w\", index, errValidate)\n\t\t}\n\t}\n\tfor index := range cfg.CodexKey {\n\t\tif errValidate := ValidateCredentialWeight(cfg.CodexKey[index].Weight); errValidate != nil {\n\t\t\treturn fmt.Errorf(\"codex-api-key[%d].weight: %w\", index, errValidate)\n\t\t}\n\t}\n\tfor index := range cfg.XAIKey {\n\t\tif errValidate := ValidateCredentialWeight(cfg.XAIKey[index].Weight); errValidate != nil {\n\t\t\treturn fmt.Errorf(\"xai-api-key[%d].weight: %w\", index, errValidate)\n\t\t}\n\t}\n\tfor providerIndex := range cfg.OpenAICompatibility {\n\t\tfor keyIndex := range cfg.OpenAICompatibility[providerIndex].APIKeyEntries {\n\t\t\tweight := cfg.OpenAICompatibility[providerIndex].APIKeyEntries[keyIndex].Weight\n\t\t\tif errValidate := ValidateCredentialWeight(weight); errValidate != nil {\n\t\t\t\treturn fmt.Errorf(\"openai-compatibility[%d].api-key-entries[%d].weight: %w\", providerIndex, keyIndex, errValidate)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":130,"sourceCodeEnd":154,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/config/weight.go#L130-L154","documentation":"Returned while validating weights inside an openai-compatibility provider block. Each provider's api-key-entries[keyIndex].weight is checked with ValidateCredentialWeight; the error names both the provider index and the key-entry index so you can locate the exact nested entry in config.yaml.","triggerScenarios":"config.yaml where openai-compatibility[p].api-key-entries[k].weight fails credentialweight.Normalize (value > 1000000 or otherwise invalid). Fires at config load or hot-reload.","commonSituations":"Nested providers make the path easy to get wrong: editing provider-level options instead of the per-key weight, or pasting a key entry whose weight was tuned for a different system with a different scale.","solutions":["Locate openai-compatibility[p] (count from 0) and its api-key-entries[k]; set weight to 1..1000000","Remember the index in the message is the array position, not a name — count entries in file order","Re-check after reload; validation covers all providers so fix every flagged entry"],"exampleFix":"# before\nopenai-compatibility:\n  - name: my-provider\n    api-key-entries:\n      - api-key: sk-...\n        weight: 2000000\n\n# after\nopenai-compatibility:\n  - name: my-provider\n    api-key-entries:\n      - api-key: sk-...\n        weight: 2","handlingStrategy":"validation","validationCode":"for p, prov := range cfg.OpenAICompatibility {\n    for k, entry := range prov.APIKeyEntries {\n        if _, err := credentialweight.Normalize(entry.Weight); err != nil {\n            return fmt.Errorf(\"openai-compatibility[%d].api-key-entries[%d].weight: %w\", p, k, err)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When editing nested openai-compatibility blocks, remember weight lives per api-key-entry, not per provider","Count array positions from 0 to map the error's indices back to the file","Prefer config templating over hand-edited YAML for repeated key entries"],"tags":["config","validation","load-balancing","openai-compatibility"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}