Validus-Risk-Management / partifact

CodeArtifact login for poetry based Python repositories.
MIT License
7 stars 2 forks source link

Problem if code_artifact_domain contains dashes #2

Closed timothestes closed 1 year ago

timothestes commented 1 year ago

Summary

If a dash is contained in the user's aws domain name, partifact has trouble parsing the url correctly.

Steps to Reproduce

Put this in pyproject.toml file:

[[tool.poetry.source]]
name = "aws"
url = "https://my-domain-123456789012.d.codeartifact.us-west-2.amazonaws.com/pypi/my-repo/simple/"
default = true

Then run this command: partifact login aws

> botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the GetAuthorizationToken operation: 2 validation errors detected: Value 'domain-123456789012' at 'domainOwner' failed to satisfy constraint: Member must have length less than or equal to 12; Value 'domain-123456789012' at 'domainOwner' failed to satisfy constraint: Member must satisfy regular expression pattern: [0-9]{12}

In this scenario, the rules that are parsing the source url are parsing the code_artifact_domain as my (instead of my-domain), and the aws_account as domain-123456789012 (instead of 123456789012)

Expected behavior:

The following url would be parsed as such:

url = "https://my-domain-123456789012.d.codeartifact.us-west-2.amazonaws.com/pypi/my-repo/simple/"

code_artifact_domain = my-domain
aws_account = 123456789012
code_artifact_repository = my-repo

Actual Behavior:

The following url is parsed as such:

url = "https://my-domain-123456789012.d.codeartifact.us-west-2.amazonaws.com/pypi/my-repo/simple/"

code_artifact_domain = my
aws_account = domain-123456789012
code_artifact_repository = my-repo
timothestes commented 1 year ago

Proposed code changes to resolve this issue.

davidsteiner commented 1 year ago

@timothestes thanks for raising this and for the proposed fix. I'll review your PR at the weekend.

timothestes commented 1 year ago

Amazing! Thank you so much!

davidsteiner commented 1 year ago

I'll clean up the unnecessary dep and release the new version tonight/sometime tomorrow. Thanks a lot for taking the time to fix this!

davidsteiner commented 1 year ago

That's done, your fix is in 0.1.6.