{"record":{"id":"1f93caf983d84978","repo":"jdx/mise","slug":"s3-url-must-include-bucket-name","errorCode":null,"errorMessage":"S3 URL must include bucket name","messagePattern":"S3 URL must include bucket name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/backend/s3.rs","lineNumber":86,"sourceCode":"    key: String,\n}\n\nimpl S3Url {\n    /// Parse an S3 URL like \"s3://bucket/path/to/object?region=us-west-2\"\n    fn parse(url_str: &str) -> Result<Self> {\n        let url = Url::parse(url_str).map_err(|e| eyre!(\"Invalid S3 URL: {e}\"))?;\n\n        if url.scheme() != \"s3\" {\n            bail!(\"URL must use s3:// scheme, got: {}\", url.scheme());\n        }\n\n        let bucket = url\n            .host_str()\n            .ok_or_else(|| eyre!(\"S3 URL must include bucket name\"))?\n            .to_string();\n\n        if bucket.is_empty() {\n            bail!(\"S3 URL must include bucket name\");\n        }\n\n        let key = url.path().trim_start_matches('/').to_string();\n\n        Ok(Self { bucket, key })\n    }\n}\n\n/// S3 backend for downloading tools from Amazon S3 or S3-compatible storage\n#[derive(Debug)]\npub(crate) struct S3Backend {\n    ba: Arc<BackendArg>,\n    /// Cached S3 client, lazily initialized\n    client: OnceCell<S3Client>,\n}\n\n#[derive(Debug, Clone, Copy)]\nstruct S3Options<'a> {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/backend/s3.rs#L68-L104","documentation":"S3Url::parse requires both a bucket (URL host) and a non-empty bucket name. This second check fires when the host parses but is empty, guaranteeing the backend always has an addressable bucket before any S3 request is built.","triggerScenarios":"Passing an s3:// URL with no host portion that resolves to an empty bucket string, e.g. \"s3:///key\" or a malformed URL where the host component is blank after parsing.","commonSituations":"Hand-editing an s3:// URL and deleting the bucket; templated config where the bucket variable expanded to empty (unset env var); copy/paste truncation.","solutions":["Include the bucket in the URL: s3://my-bucket/key","Fix the templating/env var that produced an empty bucket name","Validate the URL before handing it to mise"],"exampleFix":"// before\nMISE_S3_URL=s3:///tools/mise.tar.gz\n// after\nMISE_S3_URL=s3://my-company-bucket/tools/mise.tar.gz","handlingStrategy":"validation","validationCode":"// require a bucket before use\nfunction hasBucket(s) { const m = s.match(/^s3:\\/\\/([^/]+)\\//); return !!m && m[1].length > 0; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never template bucket names from possibly-empty env vars without a fallback check","Validate s3:// URLs include a bucket segment before saving config","Test templated config by echoing expanded values"],"tags":["s3","url","config"],"backgroundTag":"empty-required-field","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}