{"record":{"id":"4dc3a4f19069bb4e","repo":"OpenNHP/opennhp","slug":"access-url-is-required-when-data-source-type-i","errorCode":null,"errorMessage":"--access-url is required when --data-source-type is stream","messagePattern":"--access-url is required when --data-source-type is stream","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/db/main/main.go","lineNumber":68,"sourceCode":"\t\t\tif c.String(\"mode\") == \"encrypt\" {\n\t\t\t\tif c.String(\"data-source-type\") != \"\" {\n\t\t\t\t\tif !slices.Contains([]string{\"online\", \"offline\", \"stream\"}, c.String(\"data-source-type\")) {\n\t\t\t\t\t\treturn fmt.Errorf(\"invalid --data-source-type, allowed values are online, offline and stream\")\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif c.String(\"ztdo-id\") != \"\" { // update ztdo\n\t\t\t\t\tif c.String(\"source\") != \"\" || c.String(\"output\") != \"\" || c.String(\"metadata\") != \"\" || c.String(\"data-source-type\") != \"\" {\n\t\t\t\t\t\treturn fmt.Errorf(\"--source, --output, --data-source-type and --metadata are not allowed when --ztdo-id is specified\")\n\t\t\t\t\t}\n\t\t\t\t} else { // create ztdo\n\t\t\t\t\tif c.String(\"data-source-type\") != \"stream\" {\n\t\t\t\t\t\tif c.String(\"source\") == \"\" {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"--source is required when --data-source-type is not stream and --ztdo-id is not specified\")\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif c.String(\"access-url\") == \"\" {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"--access-url is required when --data-source-type is stream\")\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif c.String(\"smart-policy\") == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"--smart-policy is required in encrypt mode\")\n\t\t\t\t}\n\n\t\t\t\t// only be available in decrypt mode\n\t\t\t\tif c.String(\"ztdo\") != \"\" || c.String(\"data-private-key\") != \"\" || c.String(\"provider-public-key\") != \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"--ztdo, --data-private-key and --provider-public-key are only allowed in decrypt mode\")\n\t\t\t\t}\n\t\t\t} else if c.String(\"mode\") == \"decrypt\" {\n\t\t\t\tif c.String(\"source\") != \"\" || c.String(\"smart-policy\") != \"\" || c.String(\"access-url\") != \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"--source, --smart-policy and --access-url are only allowed in encrypt mode\")\n\t\t\t\t}\n\n\t\t\t\t// only be available in encrypt mode","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/db/main/main.go#L50-L86","documentation":"When encrypt mode is combined with --data-source-type stream, there is no local source file; the data comes from an API endpoint. The Before hook therefore requires --access-url and rejects the invocation with this error when it is empty.","triggerScenarios":"Running `nhp-device run --mode encrypt --data-source-type stream` without --access-url.","commonSituations":"Switching a previously file-based encrypt command to stream mode and forgetting to swap --source for --access-url; template scripts with an empty ACCESS_URL variable; confusing --access-url with --output.","solutions":["Add --access-url <url> pointing at the streaming API endpoint","Or if a local file was intended, use --source with --data-source-type online or offline instead of stream"],"exampleFix":"// before\nnhp-device run --mode encrypt --data-source-type stream --smart-policy policy.wasm\n// after\nnhp-device run --mode encrypt --data-source-type stream --access-url https://api.example.com/stream --smart-policy policy.wasm","handlingStrategy":"validation","validationCode":"if (flags.mode === 'encrypt' && flags['data-source-type'] === 'stream' && !flags['access-url']) {\n  throw new Error('--access-url is required when --data-source-type is stream');\n}","typeGuard":"const isStreamEncrypt = (flags) => flags.mode === 'encrypt' && flags['data-source-type'] === 'stream';","tryCatchPattern":null,"preventionTips":["Validate the URL is reachable before the encrypt run","Keep stream and file encrypt commands in separate templates","Confirm ACCESS_URL env vars resolve to non-empty values"],"tags":["cli","validation","flags"],"backgroundTag":"missing-required-flag","analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}