{"record":{"id":"880af8ddaffff56b","repo":"gleam-lang/gleam","slug":"hostname","errorCode":null,"errorMessage":"hostname","messagePattern":"hostname","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/hex/auth.rs","lineNumber":105,"sourceCode":"    fn poll_for_oauth_next_step(\n        &mut self,\n        device_authorisation: &mut hexpm::OAuthDeviceAuthorisation,\n    ) -> Result<hexpm::PollStep, Error> {\n        let request = device_authorisation.poll_token_request(&self.hex_config);\n        let response = self.runtime.block_on(self.http.send(request))?;\n        let next = device_authorisation\n            .poll_token_response(response)\n            .map_err(Error::hex)?;\n        Ok(next)\n    }\n\n    fn create_oauth_device_authorisation(\n        &mut self,\n    ) -> Result<hexpm::OAuthDeviceAuthorisation, Error> {\n        // Create a recognisable name for the client, so folks can more easily understand which\n        // session is which in the Hex console.\n        // It is expected that we can always get the hostname.\n        let hostname = hostname::get().expect(\"hostname\");\n        let client_name = format!(\"Gleam ({})\", hostname.to_string_lossy());\n\n        let request = hexpm::oauth_device_authorisation_request(\n            HEX_OAUTH_CLIENT_ID,\n            &client_name,\n            &self.hex_config,\n        );\n        let response = self.runtime.block_on(self.http.send(request))?;\n        hexpm::oauth_device_authorisation_response(HEX_OAUTH_CLIENT_ID.to_string(), response)\n            .map_err(Error::hex)\n    }\n\n    fn encrypt_and_store_oauth_refresh_token(&mut self, tokens: &OAuthTokens) -> Result<(), Error> {\n        let path = paths::global_hexpm_oauth_credentials_path();\n        let local_password = self.get_local_password()?;\n        let encrypted_refresh_token =\n            encryption::encrypt_with_passphrase(tokens.refresh_token.as_bytes(), &local_password)\n                .map_err(|error| Error::FailedToEncryptLocalHexApiKey {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/hex/auth.rs#L87-L123","documentation":"Panic from `hostname::get().expect(\"hostname\")` inside create_oauth_device_authorisation in compiler-cli/src/hex/auth.rs. The hostname crate could not determine the machine's hostname (gethostname failed or returned invalid data), so the client name for the OAuth device flow (\"Gleam (<hostname>)\") cannot be built and the process panics.","triggerScenarios":"Starting the Hex OAuth device authorisation flow on a machine where hostname::get() errors: misconfigured /etc/hostname or /proc/sys/kernel/hostname, containers without a UTS namespace set, or unusual embedded platforms.","commonSituations":"Minimal Docker containers with no hostname configured, chroot environments lacking /proc or /etc/hostname, or Windows systems where GetComputerNameEx fails.","solutions":["Set a proper hostname for the environment (e.g. `hostnameectl set-hostname name` or docker run --hostname).","Ensure /etc/hostname and /proc are present and readable in the container/chroot.","Fall back to a constant client name when the hostname is unavailable instead of panicking.","Run the OAuth authentication flow on the developer's normal machine where the hostname is configured."],"exampleFix":"// before\nlet hostname = hostname::get().expect(\"hostname\");\nlet client_name = format!(\"Gleam ({})\", hostname.to_string_lossy());\n// after\nlet host = hostname::get().unwrap_or_else(|_| \"unknown-host\".into());\nlet client_name = format!(\"Gleam ({})\", host.to_string_lossy());","handlingStrategy":"fallback","validationCode":"// Pre-check hostname availability:\nmatch hostname::get() { Ok(h) => println!(\"host: {}\", h.to_string_lossy()), Err(_) => println!(\"hostname unavailable\") }","typeGuard":"fn hostname_available() -> bool { hostname::get().is_ok() }","tryCatchPattern":"std::panic::catch_unwind(|| gleam_hex::authenticate())\n    .map_err(|_| anyhow::anyhow!(\"gleam auth panicked (hostname unavailable)\"))?;","preventionTips":["Set a hostname in containers/chroots (docker run --hostname).","Use unwrap_or with a default client name in library code.","Keep /etc/hostname and /proc mounted and readable."],"tags":["rust","hostname","oauth","panic","environment"],"backgroundTag":"missing-env-var","analyzedSha":"15b07c783065c92bb016b1b74ed0995a5259850f","analyzedAt":"2026-09-14T11:14:59.388Z","contentChangedAt":"2026-09-14T11:14:59.388Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}