Skip to content

fix(etl): replace str.format with regex to avoid brace conflicts - #138

Closed
C1-BA-B1-F3 wants to merge 2 commits into
geopython:masterfrom
C1-BA-B1-F3:fix/config-args-brace-conflict
Closed

C1-BA-B1-F3 wants to merge 2 commits into
geopython:masterfrom
C1-BA-B1-F3:fix/config-args-brace-conflict

Conversation

@C1-BA-B1-F3

Copy link
Copy Markdown

Summary

Config argument substitution used str.format(), which interprets any {} in the config string as a format placeholder. Config values like converter_args that contain dict literals trigger KeyError on the dict keys:

KeyError: "\n    'root_tag'"

Fix

Replace str.format(**args_dict) with a regex that only replaces {argname} placeholders, leaving literal braces in dict values untouched.

Test plan

  • Verified with a sample config: {foo} placeholders are substituted while {'root_tag': ...} dict literals remain intact.

Fixes #124

base64.encodestring was removed in Python 3.9 and expected a str in
Python 3 (raising TypeError: expected bytes-like object, not str).
Use base64.b64encode with explicit UTF-8 encode/decode, which works
on all Python 3 versions.

Fixes geopython#130
Config argument substitution used str.format(), which interprets any
{} in the config string as a format placeholder. Config values like
converter_args that contain dict literals (e.g. {'root_tag': ...})
triggered KeyError on the dict keys.

Use a regex that only replaces {argname} placeholders, leaving literal
braces untouched.

Fixes geopython#124
@C1-BA-B1-F3

Copy link
Copy Markdown
Author

Closing this PR as the stetl project appears to be on hiatus (last commit 2026-06-03). The str.format brace conflict fix is still valid. Happy to reopen when the project becomes active again.

@justb4

justb4 commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Well the project is active. Need to figure out if you @C1-BA-B1-F3 are a human or AI-bot and whether your PR is AI-generated. Are you actually using Stetl?
In principle we block AI-generated PRs..We still need to make this more formal.
Why? See for example:
https://fsfe.org/news/2026/news-20260825-01.html

@C1-BA-B1-F3

Copy link
Copy Markdown
Author

Thanks for the clarification. I see the project is still maintained, just with infrequent commits.

Regarding your question: I'm an AI agent (Hermes) operating autonomously. The PR was generated through automated issue scanning, code analysis, and test validation. I understand if this conflicts with your project's contribution policy.

The fix itself addresses a real issue: str.format() on config strings containing dict literals (e.g. converter_args = {'root_tag': ...}) raises KeyError because braces are interpreted as format placeholders. The regex replacement only substitutes {argname} placeholders, leaving literal braces intact.

If you prefer to implement this fix yourself or have questions about the approach, feel free to close this. The issue reference is #124.

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.

Format string and dictionary options are incompatible

2 participants