Skip to content

improve error message when using invalid path for local binary artifacts #4129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2022

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Feb 12, 2022

motivation: clearer, more actionable error message

changes:

  • catch invalid relative path for binary artifacts and emit a clear diagnostics
  • overall improve validation of binary targets path and urls
  • add tests

rdar://84365161

motivation: clearer, more actionable error message

changes:
* catch invalid relative path for binary artifacts and emit a clear diagnostics
* overall improve validation of binary targets path and urls
* add tests

rdar://84365161
@tomerd
Copy link
Contributor Author

tomerd commented Feb 12, 2022

@swift-ci please smoke test

@tomerd tomerd added the ready Author believes the PR is ready to be merged & any feedback has been addressed label Feb 12, 2022
}

guard let url = url.spm_chuzzle(), !url.isEmpty else {
observabilityScope.emit(.invalidBinaryURL(url: url, targetName: target.name))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think each error case should have some distinction, e.g. this should say that the URL is empty. Just makes it easier when someone unexpectedly hits one of these, we won't have to guess which case they are encountering. Similar for invalidLocalBinaryPath.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @neonichu we could add a special case for empty vs. invalid, tho we do print the bad URL/Path to make it obvious. wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, I missed that we are printing the URL now, that should be sufficient here.

continue
}

guard let relativePath = try? RelativePath(validating: path) else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this a do-catch and include the underlying error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is intentional - the underlying error in this case would be a generic "the path is an invalid relative path" which we fine-tune to invalidLocalBinaryPath which explains that this must be relative to the project root

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the question is what happens if the underlying error ever changes and includes useful info. I guess that's not super likely in this particular case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, that was my thinking here as it basically validates that the value is valid relative path

@tomerd tomerd merged commit 6ba2c49 into swiftlang:main Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Author believes the PR is ready to be merged & any feedback has been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants