question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugger not working invalid (or missing) template file

See original GitHub issue

Describe the bug

Lambda debug does not works, when press to “Start Debugging” button an error appear:

Invalid (or missing) template file (path must be workspace-relative, or absolute):

To Reproduce

  1. Open template.yaml
  2. Press on button “Add Debug Configuration”
  3. Configure Lambda payload and environmentVariables (optional)
  4. Press on “Start Debugging”

The .vscode/launch.json file look like this:

{
  "configurations": [
    {
      "type": "aws-sam",
      "request": "direct-invoke",
      "name": "MyFunction",
      "invokeTarget": {
        "target": "template",
        "templatePath": "template.yaml",
        "logicalId": "MyFunction"
      },
      "lambda": {
        "runtime": "nodejs12.x",
        "payload": {
          "path": "event.json"
        },
        "environmentVariables": {
          "MY_VARIABLE": "test"
        }
      }
    }
  ]
}

Expected behavior

The Lambda function start locally and VSCode debug is attached to it

Desktop (please complete the following information):

  • OS: Linux
  • Visual Studio Code Version: 1.51.1
  • AWS Toolkit Version: v1.15.0

Additional context

The template file path is correct position, I tested with a simple “stat/file/cat” in terminal and the path is correct, same behaviour using relative or absolute path.

$ file template.yaml
template.yaml: ASCII text
$ file /home/me/project/template.yaml # just an example or my absolute path
template.yaml: ASCII text

The template file is correct, I currently deploy it as SAM application without any issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:29 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
thefat32commented, Aug 29, 2022

Any idea on how to debug this problem?

If the template.yaml file contents don’t look like a SAM file, Toolkit will skip it. What do the contents look like? Also, is the file part of the vscode workspace?

The file el is generated by CDK and I can use it just fine via command line sam local invoke .... But AWS Toolkit does not load it preventing me from using sam cli Debug Configuration. We are starting the sam local invoke debugger with a VS Code preLaunchTask and attaching to the debugger to workaround this problem but it would be nice for AWS Toolkit to support the same templates sam cli does

2reactions
justinmk3commented, Jan 26, 2021

We should surface this somehow, will keep this open to track that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid (or missing) template file (path must be workspace- ...
I'm trying to debug a python function locally with VSC and I receive the following error message: Invalid (or missing) template file (path ......
Read more >
Error: Unable to Start Debugging on the Web Server
When you try to debug an ASP.NET application running on a Web server, you may get this error message: Unable to start debugging...
Read more >
Working with serverless applications - AWS Toolkit for VS ...
In the Open Folder dialog box, navigate to the serverless application folder that you want to open. Choose the Select Folder button.
Read more >
Debugging configurations for Python apps in Visual Studio Code
For now, in the Select a debug configuration menu that appears, select Python File. Debug configurations menu. Note: Starting a debugging session through...
Read more >
How to Fix the 'Preview Could Not Be Loaded' Error
Enable Safe Mode. · Make sure the theme files exist · Make sure that the Site Address (URL) is the same as the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found