Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 24, 2025

This PR addresses issue #35 by adding comprehensive test coverage for the KVP (key-value pair) splitting functionality in ComposeListOrMapElement.

Issue Summary

Issue #35 reported that parsing strings like "JAVA_OPTS=foo=bar&&baz=buzz" would fail due to incorrect splitting on all = characters instead of just the first one.

Current State

The implementation in compose_list_or_map.py line 18 already correctly uses split("=", 1) to split only on the first = character:

key, value = source_string.split("=", 1)

This means the bug was already fixed, but there was no test coverage to prevent regression.

Changes Made

Added comprehensive test cases to test_service_environment.py:

  1. test_kvp_with_multiple_equals_issue_35() - Tests the exact scenario from issue Splitting kvp on '=' creates bug if the string contains more than one '=' #35:

    element = ComposeListOrMapElement("JAVA_OPTS=foo=bar&&baz=buzz")
    self.assertEqual(element["JAVA_OPTS"], "foo=bar&&baz=buzz")
  2. test_kvp_splitting_edge_cases() - Tests various edge cases:

    • Basic KVP: KEY=value
    • Multiple equals: KEY=value=extra, KEY=a=b=c=d
    • URLs: URL=http://example.com:8080/path?param=value
    • Config strings: CONFIG=key1=val1,key2=val2
    • Complex expressions: COMPLEX=a=b&c=d&e=f
    • No value: NO_VALUE
  3. test_empty_value_handling() - Ensures existing behavior for empty values is preserved

Validation

All tests pass, confirming that:

  • The KVP splitting correctly handles multiple = characters
  • Values can contain = signs without breaking the parser
  • Edge cases are properly handled
  • No regressions are introduced

Fixes #35.


💡 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.

…sion

Co-authored-by: smurawski <4006985+smurawski@users.noreply.github.com>
Copilot AI changed the title [WIP] Splitting kvp on '=' creates bug if the string contains more than one '=' Add comprehensive test coverage for KVP splitting with multiple equals signs Jul 24, 2025
Copilot AI requested a review from usepowershell July 24, 2025 14:45
Copilot finished work on behalf of usepowershell July 24, 2025 14:45
@usepowershell usepowershell marked this pull request as ready for review July 25, 2025 15:50
@usepowershell usepowershell merged commit f4eec92 into main Jul 25, 2025
7 checks passed
@usepowershell usepowershell deleted the copilot/fix-35 branch July 25, 2025 15:50
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.

Splitting kvp on '=' creates bug if the string contains more than one '='

2 participants