Skip to content

Fix dotted data-derived keys being split as nested paths in DotDict output - #63

Draft
reubano with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-dotted-keys-in-output
Draft

Fix dotted data-derived keys being split as nested paths in DotDict output#63
reubano with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-dotted-keys-in-output

Conversation

Copilot AI commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

DotDict.__setitem__ treats . as a nested-path separator, which corrupts output when field values are promoted to dict keys — as count does with count_key. A value like 'riko pt. 1' would silently become {'riko pt': {' 1': 1}}.

Changes

  • riko/dotdict.py

    • DotDict.set_literal(key, value): stores a key verbatim via CaseInsensitiveDict.__setitem__, bypassing parse_key path-splitting entirely.
    • DotDict.__getitem__: before path-traversing a dotted key, checks key.lower() in self._store; if the full string was stored literally, returns it directly without splitting.
  • riko/modules/count.py

    • parser builds grouped output items using set_literal instead of plain dicts, so any field value (URLs, version strings, sentences) used as a count_key round-trips without structural corruption.

Before / After

from riko.modules.count import pipe

stream = [{'title': 'riko pt. 1'}, {'title': 'riko pt. 2'}]
next(pipe(stream, conf={'count_key': 'title'}))
# Before: {'riko pt': {' 1': 1}}
# After:  {'riko pt. 1': 1}

Static developer-authored dotted paths in pipe configs are unaffected — set_literal is only called at sites that promote data values to keys.

Copilot AI linked an issue Aug 5, 2026 that may be closed by this pull request
Co-authored-by: reubano <157864+reubano@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix handling of dotted keys in data-derived output Fix dotted data-derived keys being split as nested paths in DotDict output Aug 5, 2026
Copilot AI requested a review from reubano August 5, 2026 04:22
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.

Dotted keys in data-derived output

2 participants