Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug]: Lint throws error on incomplete metadata

Open
#691 0 comments 0 reactions 0 assignees View on GitHub

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

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

bug
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
  1. Open CloudFormation template with pasted template
  2. Allow linting to occur (save to manually trigger)
  3. 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:

Image
Dominant language
TypeScript
Stars
24
Forks
11
Avg merge
3d 5h
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws-cloudformation/cloudformation-languageserver

All issues in aws-cloudformation/cloudformation-languageserver

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.