Skip to content

example-client: better error handling #1862

Closed

Description

@jku

The example client has two conflicting goals:

  • provide "production-like" error messages: don't dump a 300 line stack trace if the network is down
  • be a useful debugging tool

For an example of the second I modified the example client to use some real world repositories: the error messages I got were mostly useless -- I needed to remove the error handling in the example app to see what the errors were.

So I suggest a couple of things:

  • DeserializationError needs an actual error message when it's raised -- failure to deserialize local root metadata currently looks like following, note the missing error message on last line (this can be reproduced by just modifying the local root.json file so it is invalid). This should now be fixed with Logging and error message improvements #1876
    $ ./client_example.py  download x
    Found trusted root in /home/jku/.local/share/python-tuf-client-example
    Failed to download target x: 
    
  • Maybe there should be a way to see the actual stack trace, and that should be documented in the error message. So a hypothetical normal failure would look like:
    $ ./client_example.py download x
    Found trusted root in /home/jku/.local/share/python-tuf-client-example
    Failed to download target x: Failed to transmogrify metadata
      (For detailed traceback use "-v")
    
    and then using -v would raise e instead of handling it? This would be a small change in client_example itself

Activity

  1. added
    good first issue
    on Feb 14, 2022
  2. added
    backlog
    on Feb 23, 2022
  3. ameypd commented on Sep 7, 2022

    @ameypd
    Contributor

    I would like to take this up as my first PR.

  4. ameypd commented on Nov 15, 2022

    @ameypd
    Contributor

    @jku
    I have set up the environment, please tell me how to proceed with this issue.

  5. jku commented on Nov 15, 2022

    @jku
    MemberAuthor

    you could create a failure situation to experiment with: e.g. don't start the local webserver like the instructions tell you (so you get the one line error message when running ./client_example.py download file1.txt). Then add a command line option that makes it so that you get a full stack trace when running e.g. ./client_example.py -v download file1.txt. That would be useful for debugging

  6. ameypd commented on Nov 15, 2022

    @ameypd
    Contributor

    @jku
    image
    Is this expected behaviour?

  7. jku commented on Nov 15, 2022

    @jku
    MemberAuthor

    That looks like what I'd expect yeah.

    What I'd like to have is an optional way to see the stack trace for the "failed to download...." error -- I think this is just a matter of re-raising the error instead of handling it with the simple error message in the example code.

  8. ameypd commented on Nov 15, 2022

    @ameypd
    Contributor

    client_args.add_argument( "-v", "--verbose", help="Output verbosity level (-v, -vv, ...)", action="count", default=2, )
    I changed the default to 2 from 0, but that is not the way to do it right?

  9. lukpueh commented on Nov 16, 2022

    @lukpueh
    Member

    client_args.add_argument( "-v", "--verbose", help="Output verbosity level (-v, -vv, ...)", action="count", default=2, ) I changed the default to 2 from 0, but that is not the way to do it right?

    Does it do what you wanted it to do? Or why do you think this is or isn't the way to do it?

  10. ameypd commented on Nov 18, 2022

    @ameypd
    Contributor

    @lukpueh @jku
    As I have changed its default value, I don't know how it will affect the rest of the functionality. But it is doing what is expected in terms of this issue.

  11. jku commented on Nov 18, 2022

    @jku
    MemberAuthor

    I changed the default to 2 from 0, but that is not the way to do it right?

    Ah there is a misunderstanding here. No, I don't want a raised default verbosity (sorry if my response about expected results was misleading)

    The ask here is:

    • by default the example should have short error messages only (this is what currently happens)
    • there should be a way to see the full "stack trace" on error situations (this does not exist yet)

    I have suggested that we do not need a new command line option, we can just use verbosity: if an error happens and verbosity is above the default, just let the error raise instead of handling it: this produces a stack trace output

  12. ameypd commented on Nov 23, 2022

    @ameypd
    Contributor

    @jku
    Okay. I will implement this.

  13. ameypd commented on Nov 23, 2022

    @ameypd
    Contributor

    @jku @lukpueh
    I have passed verbose as parameter to download function and if the verbose is anything other than default I am printing the stack trace.
    image

  14. added a commit that references this issue on Nov 25, 2022
    fc0d53a
  15. added a commit that references this issue on Nov 25, 2022
    6ce8bb8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backloggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions