-
Notifications
You must be signed in to change notification settings - Fork 313
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
Template provider via HTTP URL fails if given template is .json #1311
Comments
I can't reproduce with other JSON files, yet, given JSON which yields this error, works like a charm with Cloudformation directly. Will investigate more on my own, as I can't share the given JSON for security reasons. |
Out of curiosity, do you get the same error if you remove the top |
I am having the exact same problem trying to use a JSON template from the 's3' handler. It doesn't recognize that it is json and not yaml even though the extension is '.json'. NOTE: I do not have the '---' line in my json file. |
@sometxdude @wieshka could you please try to reproduce this problem with a minimal json file and paste it here? thanks. |
no response from @sometxdude and @wieshka so closing this issue |
Given --- in output is only when using Additionally, given JSON file works like a charm when used as template.path aka local file, and only when fetched from template.url (type http) it fails with error on latest Sceptre v4.3.0 on Python 3.11.6: [2023-11-02 19:47:41] - landing-zone/external/soc - Creating Stack @zaro0508 please re-open the case, I will continue to investigate the case. |
The http handler code indicates that the handler always uses jinja to render cloudformation therefore this problem is probably related to how jinja processes the file and is probably related to https://github.com/orgs/Sceptre/discussions/1238 and #1380 |
ohh oops, i'm wrong. there are different paths for jinja and non-jinja processing but anyways that's the code that does the processing. |
Pre-processing the very same JSON template with JQ yields a template which works with Sceptre, but changes (diff) in the file are only formatting related such as identation, whitespace between "key": "value" instead if "key":"value" |
Stripped template to bare minimum and I am still able to reproduce it:
|
My further investigation (monkey patching) leads to findings, that if, I extend template_handler.http handle() with respective checks - is file JSON or YAML, and load them into dict with respective library per syntax, and then dump them back as string for on return, issue gets resolved. So that, could be potential fix to address this, unless somebody has better ideas or actually can figure out why it falls apart with sample provided above which is a valid JSON. Essentially this mimics my previous observation that pre-procesing content with commonly used JQ resolves the issue as well. |
Further investigation reveals that, if JSON template, fetched by http handler, contains mixed use of spaces and tabs for identation, it will further fail with: botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the CreateStack operation: Template format error: YAML not well-formed. (line 23, column 1). |
@wieshka i suggest you use pre-commit hooks to pre format your files. We use remove-tabs, end-of-file-fixer, and trailing-whitespace |
@wieshka provided this sample template in the Sceptre Slack channel. It mixes tabs and spaces for indentation. @wieshka says it invokes the reported error. (I haven't tried to reproduce it yet.) In general I would avoid mixing tabs and spaces for indentation if you can avoid it. @zaro0508 's pre-commit hooks can help with that. But I still don't understand why it would provoke this error in CloudFormation. I want to dig deeper into this. Some questions:
|
closing this issue due to lack of response from the reporter |
Subject of the issue
If you specify
template
as type http and uri with URL to JSON file, it is treated as YAML rather JSON file.Your environment
Steps to reproduce
Point
template
with type http to valid URL pointing at .JSON filesceptre generate will yield output like this:
sceptre launch/create will fail with:
Expected behaviour
Sceptre should correctly detect that given file is JSON
Actual behaviour
Sceptre fails to detect, processes as YAML, fails.
Due to the nature of the given .json template, I won't be able to share it this time.
The text was updated successfully, but these errors were encountered: