Skip to content

Conversation

yim-lee
Copy link
Contributor

@yim-lee yim-lee commented May 17, 2023

Motivation:
When registry publish fails with client error, the current error message is "Error: failed publishing: invalid registry response status '400', expected '[201, 202]'", which doesn't provide much information on what went wrong.

rdar://109410245

Modifications:

  • Wrap 4xx status response in RegistryError.clientError and 5xx in RegistryError.serverError. Both errors include response body as details.
  • Change package-registry publish to throw the wrapped clientError such that more details (i.e., response body) get displayed.

Motivation:
When registry publish fails with client error, the current error message is "Error: failed publishing: invalid registry response status '400', expected '[201, 202]'", which doesn't provide much information on what went wrong.

rdar://109410245

Modifications:
- Wrap 4xx status response in `RegistryError.clientError` and 5xx in `RegistryError.serverError`. Both errors include response body as details.
- Change `package-registry publish` to throw the wrapped `clientError` such that more details (i.e., response body) get displayed.
@yim-lee
Copy link
Contributor Author

yim-lee commented May 17, 2023

@swift-ci please smoke test

"\(packageIdentity) version \(packageVersion) was successfully submitted to \(registryURL) and is being processed. Publishing status is available at '\(statusURL)'."
)
}
} catch RegistryError.failedPublishing(let error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure about this change - we had cases in the past where we were missing the context and the fact the error is in publishing is material context

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? That not all failedPublishing is from failed publishing?

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, I meant this change strips the the "FailedPublishing" context, and the underlying error could be hard to reason about without that context. we had a similar issue in the login flow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I reverted this part of the change. The introduction of .clientError should be good enough.

@yim-lee yim-lee force-pushed the better-publish-error branch from 63b9f7a to cc3cc1c Compare May 18, 2023 00:35
@yim-lee
Copy link
Contributor Author

yim-lee commented May 18, 2023

@swift-ci please smoke test

@yim-lee
Copy link
Contributor Author

yim-lee commented May 18, 2023

@swift-ci please test Windows platform

@yim-lee yim-lee merged commit 20d8187 into swiftlang:main May 18, 2023
@yim-lee yim-lee deleted the better-publish-error branch May 18, 2023 18:57
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request May 18, 2023
* Improve error message for 'package-registry publish'

Motivation:
When registry publish fails with client error, the current error message is "Error: failed publishing: invalid registry response status '400', expected '[201, 202]'", which doesn't provide much information on what went wrong.

rdar://109410245

Modifications:
- Wrap 4xx status response in `RegistryError.clientError` and 5xx in `RegistryError.serverError`. Both errors include response body as details.
- Change `package-registry publish` to throw the wrapped `clientError` such that more details (i.e., response body) get displayed.

* Don't lose failedPublishing context
yim-lee added a commit that referenced this pull request May 19, 2023
* Improve error message for 'package-registry publish'

Motivation:
When registry publish fails with client error, the current error message is "Error: failed publishing: invalid registry response status '400', expected '[201, 202]'", which doesn't provide much information on what went wrong.

rdar://109410245

Modifications:
- Wrap 4xx status response in `RegistryError.clientError` and 5xx in `RegistryError.serverError`. Both errors include response body as details.
- Change `package-registry publish` to throw the wrapped `clientError` such that more details (i.e., response body) get displayed.

* Don't lose failedPublishing context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants