Skip to content

Report an unknown geotag source as a bad parameter - #863

Merged
caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:report-bad-geotag-source
Oct 22, 2026
Merged

caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:report-bad-geotag-source

Conversation

@caglarpir

Copy link
Copy Markdown
Contributor

Problem

A misspelled geotag source, or a JSON source with a key the schema does not know, crashed with a traceback (exit 1):

mapillary_tools process G0017356.JPG --geotag_source foo
# ValueError: 'foo' is not a valid SourceType
mapillary_tools process G0017356.JPG --geotag_source '{"source": "gpx", "path": "track.gpx"}'
# jsonschema.exceptions.ValidationError: Additional properties are not allowed ('path' was unexpected)

Fix

factory.parse_source_option() raises MapillaryBadParameterError (exit 2). An unknown type names the supported source types and their aliases. A JSON source that fails the schema says what was rejected. This covers --geotag_source and --video_geotag_source, the a,b form, and process and video_process, which parse them the same way. Valid sources parse as before.

Verification

  • foo, gpx,foo, 123, an unknown JSON key and a bad filetypes value all exit 2 with a one-line message, on process and video_process.
  • New unit tests. Unit and integration tests, doctests, mypy --python-version 3.9, ruff check, ruff format --check and usort diff are clean.

A misspelled source type, as in --geotag_source foo or gpx,foo, failed
with a ValueError traceback ("'foo' is not a valid SourceType"), and a
JSON source with a key the schema does not know, such as

    {"source": "gpx", "path": "track.gpx"}

failed with a jsonschema ValidationError traceback. Both exited 1, as for
a crash.

They now raise MapillaryBadParameterError (exit code 2), naming the
supported source types and their aliases, or what the schema rejected
("'path' was unexpected"). This covers --geotag_source and
--video_geotag_source in process and video_process, which parse them the
same way.
@meta-cla meta-cla Bot added the cla signed label Oct 22, 2026
@caglarpir
caglarpir merged commit a843418 into mapillary:main Oct 22, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant