{"record":{"id":"95c16af2efcab438","repo":"netbirdio/netbird","slug":"create-service-config-w-95c16a","errorCode":null,"errorMessage":"create service config: %w","messagePattern":"create service config: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/service_installer.go","lineNumber":119,"sourceCode":"\t\t}\n\t}\n\n\tif runtime.GOOS == \"windows\" {\n\t\tsvcConfig.Option[\"OnFailure\"] = \"restart\"\n\t}\n\n\treturn nil\n}\n\n// Create fully configured service config for install/reconfigure\nfunc createServiceConfigForInstall() (*service.Config, error) {\n\tif err := validateJSONSocketFlags(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tsvcConfig, err := newSVCConfig()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create service config: %w\", err)\n\t}\n\n\tsvcConfig.Arguments = buildServiceArguments()\n\tif err = configurePlatformSpecificSettings(svcConfig); err != nil {\n\t\treturn nil, fmt.Errorf(\"configure platform-specific settings: %w\", err)\n\t}\n\n\treturn svcConfig, nil\n}\n\nvar installCmd = &cobra.Command{\n\tUse:   \"install\",\n\tShort: \"Install NetBird service\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tif err := setupServiceCommand(cmd); err != nil {\n\t\t\treturn err\n\t\t}\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/service_installer.go#L101-L137","documentation":"Thrown while building the system service definition for `netbird service install`. createServiceConfigForInstall calls newSVCConfig, which in practice only fails when the extra service environment variables cannot be parsed, so this wrap almost always carries a parseServiceEnvVars failure underneath.","triggerScenarios":"`netbird service install --service-env FOO` (entry without '='), `--service-env \"=value\"` (empty key), or a value containing a comma that StringSliceVar splits into a bogus second entry.","commonSituations":"Passing env vars shell-style (`--service-env NB_LOG_LEVEL debug`), forgetting quotes so the shell mangles the list, or values with commas splitting into entries that are not KEY=VALUE.","solutions":["Rewrite each --service-env entry as KEY=VALUE, e.g. --service-env NB_LOG_LEVEL=debug,CUSTOM_VAR=value","Quote the whole flag value in the shell so commas and '=' survive intact","Remove stray entries like a trailing comma producing an empty element","Re-run sudo netbird service install"],"exampleFix":"# before\nnetbird service install --service-env NB_LOG_LEVEL\n# after\nnetbird service install --service-env NB_LOG_LEVEL=debug","handlingStrategy":"validation","validationCode":"func validEnvEntries(entries []string) error {\n\tfor _, e := range entries {\n\t\tif e == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif k, _, ok := strings.Cut(e, \"=\"); !ok || strings.TrimSpace(k) == \"\" {\n\t\t\treturn fmt.Errorf(\"bad entry %q: want KEY=VALUE\", e)\n\t\t}\n\t}\n\treturn nil\n}\n\nif err := validEnvEntries(serviceEnvVars); err != nil {\n\treturn err\n}","typeGuard":null,"tryCatchPattern":"if err := createServiceConfigForInstall(); err != nil {\n\treturn fmt.Errorf(\"create service config: %w\", err)\n}\n// The chain contains 'parse service environment variables'; surface the offending entry to the user instead of retrying.","preventionTips":["Always write --service-env entries as KEY=VALUE","Quote the whole flag value in the shell","Validate env entries in scripts before invoking install"],"tags":["service","installer","environment-variables","cli","go"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}