Skip to content

fix: Register regex_replace and regex_search as Jinja macros for direct function call syntax#905

Closed
Lucas Leadbetter (lleadbet) wants to merge 1 commit intomainfrom
devin/1770924488-fix-regex-replace-macro
Closed

fix: Register regex_replace and regex_search as Jinja macros for direct function call syntax#905
Lucas Leadbetter (lleadbet) wants to merge 1 commit intomainfrom
devin/1770924488-fix-regex-replace-macro

Conversation

@lleadbet
Copy link
Copy Markdown
Contributor

fix: Register regex_replace and regex_search as Jinja macros

Summary

regex_replace and regex_search were only registered as Jinja filters (via _ENVIRONMENT.filters), which means they only worked with pipe syntax:

{{ 'abc123' | regex_replace('[0-9]+', '') }}  ✓ works
{{ regex_replace('abc123', '[0-9]+', '') }}   ✗ fails

This PR adds both functions to the _macros_list in macros.py (which feeds _ENVIRONMENT.globals), making them available as direct function calls as well. The functions are imported from filters.py — no logic is duplicated.

Review & Testing Checklist for Human

  • Verify no circular import between macros.pyfilters.py (currently filters.py does not import from macros.py, so this should be safe)
  • Test in the Connector Builder UI that {{ regex_replace('abc123def456', '[0-9]+', '') }} works as a direct function call

Notes

…ct function call syntax

Co-Authored-By: lucas.leadbetter@airbyte.io <lucas.leadbetter@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Copy Markdown

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

💡 Show Tips and Tricks

Testing This CDK Version

You can test this version of the CDK using the following:

# Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1770924488-fix-regex-replace-macro#egg=airbyte-python-cdk[dev]' --help

# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1770924488-fix-regex-replace-macro

PR Slash Commands

Airbyte Maintainers can execute the following slash commands on your PR:

  • /autofix - Fixes most formatting and linting issues
  • /poetry-lock - Updates poetry.lock file
  • /test - Runs connector tests with the updated CDK
  • /prerelease - Triggers a prerelease publish with default arguments
  • /poe build - Regenerate git-committed build artifacts, such as the pydantic models which are generated from the manifest JSON schema in YAML.
  • /poe <command> - Runs any poe command in the CDK environment
📚 Show Repo Guidance

Helpful Resources

📝 Edit this welcome message.

@lleadbet
Copy link
Copy Markdown
Contributor Author

Closed per conversation in Slack.

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.

1 participant