Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

rhbz903964 - produce better error message when permission check failed #787

Merged
merged 2 commits into from Apr 29, 2015

Conversation

huangp
Copy link
Collaborator

@huangp huangp commented Apr 28, 2015

https://bugzilla.redhat.com/show_bug.cgi?id=903964

For example, when invoke client with following command:
z -B push --push-type trans --merge-type import

There are two(maybe more) possible permission failure:

  • user is not part of the language team
  • user don't have permission to do merge type import operation

In the past what we get back is just a 401 with no body in response. Now we can tell what exactly go wrong:

  • when user is not a member for the locale
[ERROR] Execution failed: 
 * Error Message: PUT http://localhost:8080/zanata/rest/async/projects/p/jasper/iterations/i/1/r/MessageResources/translations/de?ext=comment&merge=import&assignCreditToUploader=false returned a response status of 401 Unauthorized;
 * Response From Server: Failed to obtain permission(modify-translation) with following facts([Locale(id=de, name=German), Project(name=jasper, slug=jasper, status=ACTIVE)])]
  • when user is a translator but not project maintainer (no permission to do merge import)
[ERROR] Execution failed: Failed while pushing document translations: [Failed to obtain permission(import-translation) with following facts([Project version(slug=1, status=ACTIVE)])]

userFriendlyToString =
String.format(
"Locale membership(person=%s, isTranslator=%s, isReviewer=%s, isCoordinator=%s)",
person.getName(), isTranslator, isReviewer,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is user display name. Username might be more useful to show instead or as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

username is in HAccount. Although HPerson has fetch=eager annotation on account field, you can always override this. I don't want to cause an extra database call if it's not there.

@huangp huangp force-pushed the rhbz903964-better-error-msg branch 2 times, most recently from 2e8119f to 9f7b8b7 Compare April 28, 2015 23:06
@davidmason
Copy link
Contributor

👍

@huangp huangp added the On QA label Apr 28, 2015
@huangp huangp force-pushed the rhbz903964-better-error-msg branch from 9f7b8b7 to 78a8240 Compare April 29, 2015 00:53
@huangp huangp force-pushed the rhbz903964-better-error-msg branch from 762f9b0 to 9caaf66 Compare April 29, 2015 04:51
@definite definite added Verified and removed On QA labels Apr 29, 2015
huangp pushed a commit that referenced this pull request Apr 29, 2015
rhbz903964 - produce better error message when permission check failed
@huangp huangp merged commit 479dc2d into integration/master Apr 29, 2015
@huangp huangp deleted the rhbz903964-better-error-msg branch April 29, 2015 05:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants