{"record":{"id":"44aa99e7b2366002","repo":"ruby/rubygems","slug":"unable-to-fetch-aws-metadata-from-uri-respon","errorCode":null,"errorMessage":"Unable to fetch AWS metadata from #{uri}: #{response.message} #{response.code}","messagePattern":"Unable to fetch AWS metadata from #(.+?): #(.+?) #(.+?)","errorType":"exception","errorClass":"Gem::S3URISigner::InstanceProfileError","httpStatus":null,"severity":"error","filePath":"lib/rubygems/s3_uri_signer.rb","lineNumber":192,"sourceCode":"    # Expected format: arn:aws:iam::<id>:instance-profile/<role_name>\n    role_name = iam_info[\"InstanceProfileArn\"].split(\"/\").last\n    ec2_metadata_request(EC2_IAM_SECURITY_CREDENTIALS + role_name, token: nil)\n  end\n\n  def ec2_metadata_request(url, token:)\n    request = ec2_iam_request(Gem::URI(url), Gem::Net::HTTP::Get)\n\n    response = request.fetch do |req|\n      if token\n        req.add_field \"X-aws-ec2-metadata-token\", token\n      end\n    end\n\n    case response\n    when Gem::Net::HTTPOK then\n      JSON.parse(response.body)\n    else\n      raise InstanceProfileError.new(\"Unable to fetch AWS metadata from #{uri}: #{response.message} #{response.code}\")\n    end\n  end\n\n  def ec2_metadata_token\n    request = ec2_iam_request(Gem::URI(EC2_IAM_TOKEN), Gem::Net::HTTP::Put)\n\n    response = request.fetch do |req|\n      req.add_field \"X-aws-ec2-metadata-token-ttl-seconds\", 60\n    end\n\n    case response\n    when Gem::Net::HTTPOK then\n      response.body\n    else\n      raise InstanceProfileError.new(\"Unable to fetch AWS metadata from #{uri}: #{response.message} #{response.code}\")\n    end\n  end\n","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/rubygems/s3_uri_signer.rb#L174-L210","documentation":"Error \"Unable to fetch AWS metadata from #{uri}: #{response.message} #{response.code}\" thrown in ruby/rubygems.","triggerScenarios":"Thrown at lib/rubygems/s3_uri_signer.rb:192 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the instance metadata service is reachable from this host","Verify the instance has an IAM profile attached; otherwise configure explicit s3_source credentials"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"86cbb817a38ce8477b181c17467a703ded3f2be8","analyzedAt":"2026-08-23T06:27:48.159Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}