{"record":{"id":"9389c53f3778f1ec","repo":"juanfont/headscale","slug":"parsing-user-w","errorCode":null,"errorMessage":"parsing user: %w","messagePattern":"parsing user: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/dev/main.go","lineNumber":171,"sourceCode":"\t// Wait for server to be ready.\n\thealthURL := fmt.Sprintf(\"http://127.0.0.1:%d/health\", *port)\n\n\terr = waitForHealth(ctx, healthURL, 30*time.Second)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"waiting for headscale: %w\", err)\n\t}\n\n\t// Create user.\n\tfmt.Println(\"Creating user and pre-auth key...\")\n\n\tuserJSON, err := runHS(ctx, hsBin, configPath, \"users\", \"create\", \"dev\", \"-o\", \"json\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating user: %w\", err)\n\t}\n\n\tuserID, err := extractUserID(userJSON)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parsing user: %w\", err)\n\t}\n\n\t// Create pre-auth key.\n\tkeyJSON, err := runHS(\n\t\tctx, hsBin, configPath,\n\t\t\"preauthkeys\", \"create\",\n\t\t\"-u\", strconv.FormatUint(userID, 10),\n\t\t\"--reusable\",\n\t\t\"-e\", \"24h\",\n\t\t\"-o\", \"json\",\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating pre-auth key: %w\", err)\n\t}\n\n\tauthKey, err := extractAuthKey(keyJSON)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parsing pre-auth key: %w\", err)","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/cmd/dev/main.go#L153-L189","documentation":"\"parsing user: %w\" at cmd/dev/main.go:171 wraps extractUserID(userJSON) in cmd/dev. The tool takes the JSON emitted by `headscale users create dev -o json` and extracts the numeric user id needed for the pre-auth key step. The error means the JSON could not be parsed or lacked the expected id field — i.e. the CLI's output shape did not match what the dev tool expects.","triggerScenarios":"Running a cmd/dev binary whose runHS/extractUserID expectations differ from the users-create JSON produced by the current source tree (e.g. version skew after pulling new commits that changed the CLI output); the CLI emitted an error object or empty output instead of a user record.","commonSituations":"A stale compiled cmd/dev being reused after the users API output format changed; a partially written config causing the CLI to print a warning line alongside the JSON.","solutions":["Rebuild/re-run the dev tool from the same source tree: `go run ./cmd/dev` (never mix old tool with new server source)","Inspect the CLI's JSON output manually with `headscale users create dev -o json` and report a schema-change bug if the id field is genuinely missing"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"userID, err := extractUserID(userJSON)\nif err != nil {\n\t// version skew between dev tool and CLI output schema — rebuild both from the same tree\n\treturn fmt.Errorf(\"parsing user: %w\", err)\n}","preventionTips":["Always run the dev tool from the same checkout as the server: `go run ./cmd/dev`","Treat JSON-shape changes in CLI -o json output as breaking changes for tooling"],"tags":["dev-tooling","json","parsing","version-skew"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}