Skip to content

Replace regex dependency with stdlib re in FloJsonOutputCollector#6

Merged
drQedwards merged 2 commits into
developfrom
copilot/fix-wavefront-action-issues
Feb 26, 2026
Merged

Replace regex dependency with stdlib re in FloJsonOutputCollector#6
drQedwards merged 2 commits into
developfrom
copilot/fix-wavefront-action-issues

Conversation

Copilot AI commented Feb 26, 2026

Copy link
Copy Markdown

The CI was failing because FloJsonOutputCollector used the third-party regex library solely for its recursive pattern support ((?R)), which the standard re module lacks.

Changes

  • Brace extraction: Replaced regex.findall(r'\{(?:[^{}]|(?R))*\}', ...) with a hand-rolled __find_balanced_braces() that walks the string tracking depth and string-literal boundaries — no external dep needed
  • Bug fix: Guarded json_str[i - 2] in __strip_comments with an i < 2 bounds check to prevent index errors on short strings
  • Q-promise memory API (from upstream PR Update flo_json_output_collector.py - To be Merged rootflo/wavefront#102):
    • rewind(callback, depth=None) — replays collected entries newest→oldest via recursive callback
    • iter_q(depth=None) — returns a FloIterator enabling while/for hybrid traversal
  • Logger: get_logger().warn()get_logger().warning() (deprecated alias removed)

Usage example

collector = FloJsonOutputCollector()
collector.append('{"a":1} // comment')
collector.append('{"b":2} /* comment */')

# Promise-style replay
collector.rewind(lambda entry: print("Q:", entry))
# Q: {'b': 2}
# Q: {'a': 1}

# While-for hybrid
it = collector.iter_q()
while it.has_next():
    for step in it.next():
        print("step:", step)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: drQedwards <213266729+drQedwards@users.noreply.github.com>
@drQedwards drQedwards marked this pull request as ready for review February 26, 2026 18:14
Copilot AI changed the title [WIP] Fix issues with Wavefront action workflow Replace regex dependency with stdlib re in FloJsonOutputCollector Feb 26, 2026
@drQedwards drQedwards merged commit e71c13e into develop Feb 26, 2026
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