Skip to content

fix(osmsg/handlers.py): --length silently produced no output unless the same key was also passed to --tags - #58

Merged
kshitijrajsharma merged 1 commit into
osgeonepal:masterfrom
gauravbarall:fix/osmsg-length
Aug 24, 2026
Merged

fix(osmsg/handlers.py): --length silently produced no output unless the same key was also passed to --tags#58
kshitijrajsharma merged 1 commit into
osgeonepal:masterfrom
gauravbarall:fix/osmsg-length

Conversation

@gauravbarall

Copy link
Copy Markdown
Collaborator

The bug

In the default mode (no --all, no --keys), ChangefileHandler._accumulate decided which tag keys to record stats for by checking cfg["additional_tags"] (i.e. --tags) only.

--length is documented as its own independent flag, but the code never consulted cfg["length"] when building that list. As a result, any key passed to --length that wasn't also repeated in --tags never got a TagValueStat written for it — no error, no warning, just an empty/zero result.

The fix

Track the union of --tags and --length keys instead of just --tags.

The tracked keys are computed once in __init__ as self._tracked_keys, rather than re-reading cfg["additional_tags"] for every element.

Before

uv run osmsg --length highway --last day

highway_len_m comes back as 0 for every row.

ChangefileHandler never accumulated anything for highway because --length doesn't feed into additional_tags.

After

The same command now correctly reports the summed length of created highway=* ways.

--length works independently and also correctly picks up keys that are in --length but not in --tags when both are passed together.

For example:

uv run osmsg --tags building --length highway --last day

Previously, highway was silently dropped because only keys from --tags were tracked. It is now correctly included.

--length keys were only tracked if the same key was also passed to --tags; now the tracked-key set is the union of both.
@kshitijrajsharma
kshitijrajsharma merged commit 4ab5893 into osgeonepal:master Aug 24, 2026
9 checks passed
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

Successfully merging this pull request may close these issues.

2 participants