{"record":{"id":"093d7f1e037bf138","repo":"influxdata/influxdb","slug":"token-creation-to-return-full-token-info","errorCode":null,"errorMessage":"token creation to return full token info","messagePattern":"token creation to return full token info","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"influxdb3/src/commands/create/token.rs","lineNumber":96,"sourceCode":"            created_at: chrono::Utc::now().timestamp_millis(),\n            updated_at: None,\n            updated_by: None,\n            expiry_millis: i64::MAX,\n            permissions: vec![], // Admin tokens don't need explicit permissions\n        });\n\n        CreateTokenWithPermissionsResponse::from_token_info(token_info, token)\n            .ok_or_else(|| \"Failed to create token response\".into())\n    } else {\n        let json_body = if config.regenerate {\n            println!(\"Are you sure you want to regenerate admin token? Enter 'yes' to confirm\",);\n            let mut confirmation = String::new();\n            io::stdin().read_line(&mut confirmation)?;\n            if confirmation.trim() == \"yes\" {\n                client\n                    .api_v3_configure_regenerate_admin_token()\n                    .await?\n                    .expect(\"token creation to return full token info\")\n            } else {\n                return Err(\"Cannot regenerate token without confirmation\".into());\n            }\n        } else {\n            client\n                .api_v3_configure_create_admin_token()\n                .await?\n                .expect(\"token creation to return full token info\")\n        };\n        Ok(json_body)\n    }\n}\n\nfn generate_offline_token() -> String {\n    create_token_and_hash().0\n}\n\npub(crate) async fn handle_named_admin_token_creation(","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/influxdata/influxdb/blob/d28e26e048401c53cbb98cf2d6ab0cf1e98048ca/influxdb3/src/commands/create/token.rs#L78-L114","documentation":"When running `influxdb3 create token --admin --regenerate` (after typing 'yes' at the confirmation prompt), the CLI POSTs to /api/v3/configure/token/admin/regenerate and the client returns Result<Option<CreateTokenWithPermissionsResponse>>. The .expect panics when the server answered successfully but the body was missing or did not contain full token info, i.e. the Option came back None. It means the endpoint replied without the JSON token payload the CLI requires — most often because --host points at the wrong endpoint or the server is an older version.","triggerScenarios":"Running `influxdb3 create token --admin --regenerate` where the request succeeds (2xx) but the response body is empty or not the full token JSON: pointing --host at the main server instead of the admin-token-recovery endpoint (the flag help says regeneration needs --host set to the address configured via --admin-token-recovery-http-bind), a CLI/server version mismatch where the endpoint returns a different shape, or a proxy returning 200 with an empty body.","commonSituations":"Regenerating the operator token after it was lost, while the recovery endpoint is on a different port and --host still defaults to http://127.0.0.1:8181; mixing an influxdb3 CLI from one release with a server binary from another; a load balancer or sidecar intercepting the POST and returning an empty 200.","solutions":["Point --host at the admin token recovery endpoint: influxdb3 create token --admin --regenerate --host http://<recovery-bind-address> (the address given to --admin-token-recovery-http-bind on the server).","Verify the CLI and server are the same InfluxDB 3 version — older servers return a reduced/no body for the regenerate endpoint.","Reproduce with curl -X POST against the chosen --host and confirm the response is a JSON body with token info; if a proxy returns an empty 200, bypass or fix it.","If it persists on matched versions, report it: the CLI should turn the None into an error message instead of .expect (compare the offline branch which uses ok_or_else)."],"exampleFix":"# before\ninfluxdb3 create token --admin --regenerate --host http://127.0.0.1:8181\n# -> panic: token creation to return full token info\n\n# after: target the admin token recovery endpoint\ninfluxdb3 create token --admin --regenerate \\\n  --host http://127.0.0.1:8182   # the --admin-token-recovery-http-bind address","handlingStrategy":"validation","validationCode":"// If calling the client directly, handle the None instead of expect:\nmatch client.api_v3_configure_regenerate_admin_token().await? {\n    Some(resp) => Ok(resp),\n    None => Err(\"server returned no token info; is --host the admin-token-recovery endpoint?\".into()),\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["For --regenerate, always pass --host pointing at the recovery endpoint (--admin-token-recovery-http-bind), not the main API port.","Keep CLI and server versions in lockstep; regeneration endpoints change shape between releases.","Confirm with curl that the endpoint returns a JSON body with token info before scripting the CLI."],"tags":["rust","influxdb","cli","token","admin-token","api-response","panic"],"backgroundTag":"empty-api-response","analyzedSha":"d28e26e048401c53cbb98cf2d6ab0cf1e98048ca","analyzedAt":"2026-08-16T19:53:34.623Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}