Skip to content

Exception: URL error reason: unknown url type: arn #49

@sp-andres-diaz

Description

@sp-andres-diaz

Hi,

I got this error when perform an apt-get update :

Traceback (most recent call last):
  File "/usr/lib/apt/methods/s3", line 556, in <module>
    method = S3_method(config)
  File "/usr/lib/apt/methods/s3", line 369, in __init__
    self.iam.get_credentials()
  File "/usr/lib/apt/methods/s3", line 159, in get_credentials
    raise Exception("URL error reason: %s" % e.reason)
Exception: URL error reason: unknown url type: arn

As far as I see, the problem is related in the way of how request is made in line 190 (master branch):

data = self.__request_json(urllib.parse.urljoin(self.credentials_metadata, self.iamrole))

In my case self.credentials_metadata has the correct value (i.e. http://169.254.169.254/latest/meta-data/iam/security-credentials/), but the self.iamrole has the following format: arn:aws:iam::00000000:role/xxxx, as a result, the urljoin return only the iamrole (because of the format with :).

Interactive example:

x = "http://foo.bar/path/"
y = "arn:something"
import urllib.parse
urllib.parse.urljoin(x,y)

'arn:something'

Note that if you change arn:xxxx by any other prefix (i.e: abc:123) the problem does not appear.

As workaround I substitute the urljoin function by a simple str.join function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions