[Bug]: Lint throws error on incomplete metadata
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python, typescript
- Domain
- developer-experience, tooling
Research direction
Reproduce the template in the issue, then inspect the lint integration at PyodideWorkerManager.ts and the cfn-lint path through config.py's set_template_args. Verify that an incomplete Metadata value no longer prevents the WrongProperty diagnostic from appearing, while the malformed section still receives appropriate handling.
Written by the indexing model from the issue text.
Description
Describe the bug
While editing the metadata section of a template, lint throws an error and all other lint diagnostics are unable to show.
Example Template:
AWSTemplateFormatVersion: '2010-09-09'
Metadata:
c
Resources:
Bucket:
Type: AWS::S3::Bucket
Properties:
WrongProperty: asdf
Since the Metadata section is incomplete Lint errors out. Removing the Metadata section displays a valid lint error on WrongProperty.
Steps to reproduce
- Open CloudFormation template with pasted template
- Allow linting to occur (save to manually trigger)
- Observe error diagnostic
Expected behavior
Lint should not error out and valid lint diagnostics are created
CloudFormation template (if applicable)
AWSTemplateFormatVersion: '2010-09-09'
Metadata:
c
Resources:
Bucket:
Type: AWS::S3::Bucket
Properties:
WrongProperty: asdf
Language Server version
1.12 beta
Editor/IDE
VS Code 1.138.0
Operating System
macOS
Node.js version
v20.20.2
Logs
[12:05:37 PM] INFO: [CfnLintService] cfn-lint version: 1.57.0 (initialized)
[12:05:49 PM] INFO: [SchemaStore] Combined schemas
Public: 1787
Private: 0
Sam: 13
Total: 1800
[12:06:18 PM] ERROR: [CfnLintService] Error linting template by file
err: {
"type": "Error",
"message": "PythonError: Traceback (most recent call last):\n File \"/lib/python313.zip/_pyodide/_base.py\", line 597, in eval_code_async\n await CodeRunner(\n ...<9 lines>...\n .run_async(globals, locals)\n File \"/lib/python313.zip/_pyodide/_base.py\", line 411, in run_async\n coroutine = eval(self.code, globals, locals)\n File \"<exec>\", line 1, in <module>\n File \"<exec>\", line 125, in lint_uri\n File \"/lib/python3.13/site-packages/cfnlint/api.py\", line 163, in lint_by_config\n return list(runner.run())\n File \"/lib/python3.13/site-packages/cfnlint/runner/cli.py\", line 250, in run\n yield from run_template_by_file_paths(self.config, self.rules)\n File \"/lib/python3.13/site-packages/cfnlint/runner/template/runner.py\", line 213, in run_template_by_file_paths\n yield from run_template_by_file_path(\n filename, config, rules, ignore_bad_template\n )\n File \"/lib/python3.13/site-packages/cfnlint/runner/template/runner.py\", line 145, in run_template_by_file_path\n yield from _run_template(filename, template, config, rules)\n File \"/lib/python3.13/site-packages/cfnlint/runner/template/runner.py\", line 118, in _run_template\n config.set_template_args(template)\n ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^\n File \"/lib/python3.13/site-packages/cfnlint/config.py\", line 723, in set_template_args\n configs = template.get(\"Metadata\", {}).get(\"cfn-lint\", {}).get(\"config\", {})\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nAttributeError: 'str_node' object has no attribute 'get'\n",
"stack":
Error: PythonError: Traceback (most recent call last):
File "/lib/python313.zip/_pyodide/_base.py", line 597, in eval_code_async
await CodeRunner(
...<9 lines>...
.run_async(globals, locals)
File "/lib/python313.zip/_pyodide/_base.py", line 411, in run_async
coroutine = eval(self.code, globals, locals)
File "<exec>", line 1, in <module>
File "<exec>", line 125, in lint_uri
File "/lib/python3.13/site-packages/cfnlint/api.py", line 163, in lint_by_config
return list(runner.run())
File "/lib/python3.13/site-packages/cfnlint/runner/cli.py", line 250, in run
yield from run_template_by_file_paths(self.config, self.rules)
File "/lib/python3.13/site-packages/cfnlint/runner/template/runner.py", line 213, in run_template_by_file_paths
yield from run_template_by_file_path(
filename, config, rules, ignore_bad_template
)
File "/lib/python3.13/site-packages/cfnlint/runner/template/runner.py", line 145, in run_template_by_file_path
yield from _run_template(filename, template, config, rules)
File "/lib/python3.13/site-packages/cfnlint/runner/template/runner.py", line 118, in _run_template
config.set_template_args(template)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "/lib/python3.13/site-packages/cfnlint/config.py", line 723, in set_template_args
configs = template.get("Metadata", {}).get("cfn-lint", {}).get("config", {})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str_node' object has no attribute 'get'
at PyodideWorkerManager.handleWorkerMessage (webpack://aws/cloudformation-languageserver/src/services/cfnLint/PyodideWorkerManager.ts:227:19)
at Worker.emit (node:events:509:28)
at MessagePort.<anonymous> (node:internal/worker:350:14)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:843:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
}
Additional context
Full Diagnostic message:
[{
"resource": "/Users/chrisqm/workplace_2/cloudformation-language-server/cloudformation-languageserver/asdjfklasdfj.yaml",
"owner": "_generated_diagnostic_collection_name_#3",
"code": "LINT_ERROR",
"severity": 8,
"message": "CFN Lint Error: PythonError: Traceback (most recent call last):\n File \"/lib/python313.zip/_pyodide/_base.py\", line 597, in eval_code_async\n await CodeRunner(\n ...<9 lines>...\n .run_async(globals, locals)\n File \"/lib/python313.zip/_pyodide/_base.py\", line 411, in run_async\n coroutine = eval(self.code, globals, locals)\n File \"<exec>\", line 1, in <module>\n File \"<exec>\", line 125, in lint_uri\n File \"/lib/python3.13/site-packages/cfnlint/api.py\", line 163, in lint_by_config\n return list(runner.run())\n File \"/lib/python3.13/site-packages/cfnlint/runner/cli.py\", line 250, in run\n yield from run_template_by_file_paths(self.config, self.rules)\n File \"/lib/python3.13/site-packages/cfnlint/runner/template/runner.py\", line 213, in run_template_by_file_paths\n yield from run_template_by_file_path(\n filename, config, rules, ignore_bad_template\n )\n File \"/lib/python3.13/site-packages/cfnlint/runner/template/runner.py\", line 145, in run_template_by_file_path\n yield from _run_template(filename, template, config, rules)\n File \"/lib/python3.13/site-packages/cfnlint/runner/template/runner.py\", line 118, in _run_template\n config.set_template_args(template)\n ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^\n File \"/lib/python3.13/site-packages/cfnlint/config.py\", line 723, in set_template_args\n configs = template.get(\"Metadata\", {}).get(\"cfn-lint\", {}).get(\"config\", {})\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nAttributeError: 'str_node' object has no attribute 'get'\n",
"source": "cfn-lint",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 1,
"modelVersionId": 69,
"origin": "extHost1"
}]
Screenshot:
- Dominant language
- TypeScript
- Stars
- 24
- Forks
- 11
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aws-cloudformation/cloudformation-languageserver
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
aws-cloudformation/cloudformation-languageserver#709 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
aws-cloudformation/cloudformation-languageserver#706 ·
Maintainers usually reply within 2 days
All issues in aws-cloudformation/cloudformation-languageserver
Similar issues
-
ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
xavxyz/bei-shan-lin-shui#57 ·
Maintainers usually reply within 1 day
-
[BUG] rag: sentence content can cross the reported sentence boundariesPossibly taken @LJK-ikun claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
README: the Resource URI Schemas example's file://documents/* pattern only matches that literal URIOpen
Difficulty 1/5 Under an hour Newbie friendliness 88/100
platformatic/mcp#361 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
siyuan-note/siyuan#20799 · 7 comments ·
Maintainers usually reply within 1 day