{"record":{"id":"c8c66236ec38f63a","repo":"affaan-m/ECC","slug":"invalid-managed-hook-handler-at-label-invalid-allowedenvvars","errorCode":null,"errorMessage":"Invalid managed hook handler at ${label}: invalid allowedEnvVars","messagePattern":"Invalid managed hook handler at (.+?): invalid allowedEnvVars","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/install/claude-settings.js","lineNumber":115,"sourceCode":"    throw new Error(`Invalid managed hook handler at ${label}: async requires command type`);\n  }\n  if (hook.type === 'http') {\n    if (!isNonEmptyString(hook.url)) {\n      throw new Error(`Invalid managed hook handler at ${label}: invalid url`);\n    }\n    if (\n      hook.headers !== undefined\n      && (!isJsonObject(hook.headers)\n        || !Object.values(hook.headers).every(value => typeof value === 'string'))\n    ) {\n      throw new Error(`Invalid managed hook handler at ${label}: invalid headers`);\n    }\n    if (\n      hook.allowedEnvVars !== undefined\n      && (!Array.isArray(hook.allowedEnvVars)\n        || !hook.allowedEnvVars.every(isNonEmptyString))\n    ) {\n      throw new Error(`Invalid managed hook handler at ${label}: invalid allowedEnvVars`);\n    }\n    return;\n  }\n  if (!isNonEmptyString(hook.prompt)) {\n    throw new Error(`Invalid managed hook handler at ${label}: invalid prompt`);\n  }\n  if (hook.model !== undefined && !isNonEmptyString(hook.model)) {\n    throw new Error(`Invalid managed hook handler at ${label}: invalid model`);\n  }\n}\n\nfunction validateManagedHooks(managedHooks, label = 'managed hooks') {\n  if (!isJsonObject(managedHooks)) {\n    throw new Error(`Invalid ${label}: expected a JSON object`);\n  }\n  if (Object.keys(managedHooks).length === 0) {\n    throw new Error(`Invalid ${label}: expected at least one hook event`);\n  }","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/install/claude-settings.js#L97-L133","documentation":"For http hooks, the optional 'allowedEnvVars' field must be an array of non-empty strings naming environment variables the hook may read. validateHookHandler throws this error when it is not an array or contains blank/non-string entries.","triggerScenarios":"validateManagedHooks encounters {type:'http', url:'x', allowedEnvVars:'ENV_VAR'} (string not array), allowedEnvVars:[''], allowedEnvVars:[42], or allowedEnvVars:{} .","commonSituations":"Specifying a single env var as a bare string instead of a one-element array; env var names with trailing whitespace; a config generator that emits null entries; misunderstanding that the field is a list, not a map.","solutions":["Wrap the value in an array: allowedEnvVars:[\"MY_API_TOKEN\"].","Remove empty or whitespace-only entries from the array.","Ensure every entry is a string env var name, not a value or number.","Validate with Array.isArray and every(isNonEmptyString) before calling the API."],"exampleFix":"// before\n{ \"type\": \"http\", \"url\": \"https://api.example.com\", \"allowedEnvVars\": \"GITHUB_TOKEN\" }\n// after\n{ \"type\": \"http\", \"url\": \"https://api.example.com\", \"allowedEnvVars\": [\"GITHUB_TOKEN\"] }","handlingStrategy":"validation","validationCode":"const bad = hooks.filter(h=>h.type==='http'&&h.allowedEnvVars!==undefined&&(!Array.isArray(h.allowedEnvVars)||!h.allowedEnvVars.every(v=>typeof v==='string'&&v.trim()!==''))); if (bad.length) throw new Error('allowedEnvVars must be string[]');","typeGuard":"const hasValidEnvVars = (h) => h.allowedEnvVars === undefined || (Array.isArray(h.allowedEnvVars) && h.allowedEnvVars.every(v => typeof v === 'string' && v.trim() !== ''));","tryCatchPattern":"try { installHooks(cfg); } catch (e) { if (e.message.includes('invalid allowedEnvVars')) { console.error('allowedEnvVars must be an array of non-empty strings:', e.message); process.exitCode = 1; } else throw e; }","preventionTips":["Always use array form even for one variable.","Use exact env var names (UPPER_SNAKE).","Trim entries before install."],"tags":["config","validation","env"],"backgroundTag":"invalid-config-value","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}