Skip to content
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

update-tagblock fails on malformed group field in tagblock #40

Open
pwoods25443 opened this issue Jan 19, 2023 · 0 comments
Open

update-tagblock fails on malformed group field in tagblock #40

pwoods25443 opened this issue Jan 19, 2023 · 0 comments

Comments

@pwoods25443
Copy link
Member

pwoods25443 commented Jan 19, 2023

The bug reported in Version: v0.1.5.dev4 (dev branch)

The group tag decode raises ValueError when the group tag is malformed. This example came up in some historical AIS data we were ingesting

\g:1-2--001,c:1326055296*3C\!AIVDM,2,1,3,A,E7`B1:dW7oHth@@@@@@@@@@@@@@6@
6R;mMQM@10888Qr8`8888888888,0*65
\g:2-2--001*41\!AIVDM,2,2,3,A,8880,0*1D

when you run

cat nmea.txt | ais-tools update-tagblock -s 99

you get

Traceback (most recent call last):
  File "/home/paul/.local/lib/python3.9/site-packages/ais_tools/tagblock.py", line 141, in decode_tagblock
    [int(part) for part in value.split("-")])))
  File "/home/paul/.local/lib/python3.9/site-packages/ais_tools/tagblock.py", line 141, in <listcomp>
    [int(part) for part in value.split("-")])))
ValueError: invalid literal for int() with base 10: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/paul/.local/bin/ais-tools", line 8, in <module>
    sys.exit(cli())
  File "/home/paul/.local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/paul/.local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/paul/.local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/paul/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/paul/.local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/paul/.local/lib/python3.9/site-packages/ais_tools/cli.py", line 104, in update_tagblock
    output.write(tagblock.update_tagblock(nmea.strip(), **fields))
  File "/home/paul/.local/lib/python3.9/site-packages/ais_tools/tagblock.py", line 159, in update_tagblock
    tagblock = decode_tagblock(tagblock_str)
  File "/home/paul/.local/lib/python3.9/site-packages/ais_tools/tagblock.py", line 152, in decode_tagblock
    raise DecodeError('Unable to decode tagblock string')
_ais.DecodeError: Unable to decode tagblock string
@pwoods25443 pwoods25443 changed the title Bug in tagblock decode update-tagblock fails on malformed group field in tagblock Jan 19, 2023
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

No branches or pull requests

1 participant