{"record":{"id":"c4defa4d0f9c233b","repo":"OpenNHP/opennhp","slug":"authserviceid-is-required","errorCode":null,"errorMessage":"AuthServiceId is required","messagePattern":"AuthServiceId is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/agent/main/main.go","lineNumber":480,"sourceCode":"\n\t// asp-id: default to the first resource entry's AuthServiceId if available,\n\t// falling back to \"example\" for the standard demo deployment.\n\tdefaultAspId := \"example\"\n\tif aspId == \"\" {\n\t\tif kt := a.FirstKnockTarget(); kt != nil && kt.AuthServiceId != \"\" {\n\t\t\tdefaultAspId = kt.AuthServiceId\n\t\t}\n\t}\n\tif aspId == \"\" {\n\t\tval, readErr := promptInput(reader, \"AuthServiceId (asp-id)\", defaultAspId)\n\t\tif readErr != nil {\n\t\t\tfmt.Printf(\"\\n  %s❌ Failed to read input:%s %v\\n\\n\", colorYellow, colorReset, readErr)\n\t\t\treturn readErr\n\t\t}\n\t\taspId = strings.TrimSpace(val)\n\t\tif aspId == \"\" {\n\t\t\tfmt.Printf(\"\\n  %s❌ AuthServiceId is required%s\\n\\n\", colorYellow, colorReset)\n\t\t\treturn fmt.Errorf(\"AuthServiceId is required\")\n\t\t}\n\t}\n\n\t// res-id: default from the matching resource.toml entry for this asp-id,\n\t// falling back to \"demo\" for the standard demo deployment.\n\tdefaultResId := \"demo\"\n\tif resId == \"\" {\n\t\tif kt := a.FindKnockTargetByAspId(aspId); kt != nil && kt.ResourceId != \"\" {\n\t\t\tdefaultResId = kt.ResourceId\n\t\t}\n\t}\n\tif resId == \"\" {\n\t\tval, readErr := promptInput(reader, \"ResourceId (res-id)\", defaultResId)\n\t\tif readErr != nil {\n\t\t\tfmt.Printf(\"\\n  %s❌ Failed to read input:%s %v\\n\\n\", colorYellow, colorReset, readErr)\n\t\t\treturn readErr\n\t\t}\n\t\tresId = strings.TrimSpace(val)","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/agent/main/main.go#L462-L498","documentation":"runRegisterApp performs an interactive app registration flow. The AuthServiceId (asp-id) prompt is mandatory; if the user submits an empty line (just Enter), the command prints a colored error and returns \"AuthServiceId is required\" so main() exits non-zero instead of registering an app without an identity.","triggerScenarios":"Interactive `register` command reaches the asp-id prompt and the user presses Enter without typing a value; stdin is EOF/closed so the read yields an empty string rather than a read error.","commonSituations":"Running the command from a script or CI with piped/closed stdin; user not knowing the asp-id registered in resource.toml; accidentally skipping the prompt.","solutions":["Enter the AuthServiceId exactly as configured in resource.toml when prompted.","Pipe the value if automating: `echo \"my-asp-id\" | nhp-agent register ...` (ensure stdin stays open for later prompts).","Check resource.toml [[Resources]] entries for the valid asp-id values first.","If non-interactive use is needed, add/pass a --asp-id flag instead of relying on the prompt."],"exampleFix":"// before (non-interactive shell)\nnhp-agent register < /dev/null   # empty asp-id\n\n// after\nprintf 'my-app-id\\n' | nhp-agent register","handlingStrategy":"validation","validationCode":"aspId := strings.TrimSpace(promptedValue)\nif aspId == \"\" {\n    return fmt.Errorf(\"AuthServiceId is required\")\n}","typeGuard":null,"tryCatchPattern":"if err := runRegisterApp(...); err != nil {\n    fmt.Fprintf(os.Stderr, \"register: %v\\n\", err)\n    os.Exit(1)\n}","preventionTips":["Keep stdin open when scripting; don't redirect from /dev/null.","Confirm the asp-id exists in resource.toml before prompting.","Add a non-interactive --asp-id flag for automation."],"tags":["cli","validation","registration","go"],"backgroundTag":"empty-required-field","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"}