Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [PYTHON] code generation breaks with jmustache 1.16 #20375

Open
alexey-komarov opened this issue Dec 25, 2024 · 0 comments
Open

[BUG] [PYTHON] code generation breaks with jmustache 1.16 #20375

alexey-komarov opened this issue Dec 25, 2024 · 0 comments

Comments

@alexey-komarov
Copy link

alexey-komarov commented Dec 25, 2024

I understand this is not a critical issue since the default version of jmustache works fine. However, I spent a day troubleshooting this so decided to share my findings to help others avoid similar struggles.

I attempted to build a Python client using a Gradle plugin but ended up with broken code that looks like this:

        _response_types_map: Dict[str, Optional[str]] = {
            '200': None,
        }        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )

Further investigation revealed the problem originates from the new version of jmustache. This library had not been updated since 2019, but in November 2023, the author released version 1.16, which is pulled in by another Gradle plugin I use. As far as I can understand, the issue arises from a change in how the new version processes templates that included with {{>. Version 1.15 appends a newline (\n) at the end of a file if it's missing, while version 1.16 does not (which might actually be more correct behavior).

Specifically, the inner template partial_api.mustache lacks a newline at the end. As a result, jmustache generates Python code with broken indentation.

Interestingly, this issue is a regression introduced after this commit. Before this commit, the code generation was correct since partial_api.mustache did not exist yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant