metomi / rose

:rose: Rose is a toolkit for writing, editing and running application configurations.
https://metomi.github.io/rose/
GNU General Public License v3.0
56 stars 53 forks source link

rosie: unhelpful error message "invalid suite ID" #2225

Open oliver-sanders opened 6 years ago

oliver-sanders commented 6 years ago

Rosie raised a SuiteIdTextError in the event that svn info fails irrespective of the reason which is confusing to users. e.g. locked keyring.

Traceback (most recent call last):
  File "/usr/lib64/python2.6/runpy.py", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.6/runpy.py", line 34, in _run_code
    exec code in run_globals
  File "path/to/rose/lib/python/rosie/vc.py", line 711, in <module>
    main()
  File "path/to/rose/lib/python/rosie/vc.py", line 705, in main
    return globals()[name](argv[1:])
  File "path/to/rose/lib/python/rosie/vc.py", line 555, in create
    from_id = SuiteId(id_text=from_id.to_string_with_version())
  File "path/to/rose/lib/python/rosie/suite_id.py", line 519, in to_string_with_version
    raise SuiteIdTextError(location)
rosie.suite_id.SuiteIdTextError: https://example.com/path/to/suite@HEAD: invalid suite ID
sadielbartholomew commented 5 years ago

A user has observed this exact traceback, but reports that the svn info command works & returns a success status. Therefore the scope of this Issue might be wider than the title & current description suggest. I am amending the title of this Issue accordingly.

nhsavage commented 4 years ago

I am not sure if it is connected, but I have had this happen to me when I have copied and pasted a suite ID from a trac ticket and somehow got unprintable characters into my command line prompt. This confuses rosie copy but as the suite ID that it prints still have the unprintable characters, it looks like the suite ID is correct. This may be a "don't do that then".

oliver-sanders commented 4 years ago

That would be a different issue to do with sanitising inputs.

This may be a "don't do that then".

Maybe, but it might be something we can address in another issue.

Can you find out what these unprintable characters are and send back an example string. We might be able to do something.

nhsavage commented 4 years ago

I can reproduce the problem by copying a suite Id from a trac ticket, but I don't know how to turn that into an example string. The result of cat -A is:

fris@vld359> echo ​u-bn027|cat -A
M-bM-^@M-^Ku-bn027$

and the actual string is: ​u-bn027 (non printable character is before the u)

oliver-sanders commented 4 years ago

Hmm, that string contains control characters, I've not been able to replicate this, are you copying text from a browser running on Windows to Linux via a VDI client perchance?

Unfortunately you can't just regex them out as they are instructions to move the terminal cursor position. To expand out control characters (like echo does) you need the functionality of a vtxxx terminal emulator. There are a few Python emulators kicking about which have simple functions to parse control chars out of strings, however, none of these are in the standard library so we can't do this for any Python2 Rose release (though could possibly do for Python3).

For now the best we can do is to detect control characters and raise a more informative error message. If this makes sense I'll sling up a separate issue to do that for an upcomming Python2 Rose release.

nhsavage commented 4 years ago

thanks - I can replicate this purely within a Linux environment, just by copying from Firefox a suite ID which is also a Trac link to a rose suite (i.e. what is displayed by [roses-u.x:source:b/q/7/9/5/trunk u-bq795] ) I think the control characters come from arrow inside a box in front of the suite ID.

I think your proposed change would have saved me a heck of a lot of frustration and would be a very good thing.