aws / aws-toolkit-jetbrains

AWS Toolkit for JetBrains - a plugin for interacting with AWS from JetBrains IDEs
https://plugins.jetbrains.com/plugin/11349-aws-toolkit
Apache License 2.0
748 stars 214 forks source link

Can't debug Lambda declared as a "AWS::Lambda::Function" #3558

Open noesnaterse opened 1 year ago

noesnaterse commented 1 year ago

Describe the bug

After installing the toolkit, I wanted to debug a Lambda function. This doesn't work, but I don't know the exact error because it isn't there completely.

This is problematic, because how am I going to fix that, if I cannot read the error message. pycharm-aws-error-notification-screen

To reproduce

  1. Download the test project https://github.com/noesnaterse/aws-sam
  2. In PyCharm go to Run -> Edit configurations
  3. Copy the information as can be seen in this screen run_configuration
  4. Press run
  5. Get the error

Expected behavior The Lambda function would just run

Your Environment

rli commented 1 year ago
2023-03-28 15:36:32,979 [2487551]   INFO - #c.i.e.r.ExecutionUtil - Error running '[Local] WidgetHandlerF8A613CA':<br>logicalId: String): Stri…xtValue()
        }
    } must not be null
java.lang.NullPointerException: logicalId: String): Stri…xtValue()
        }
    } must not be null
    at software.aws.toolkits.jetbrains.services.lambda.sam.SamTemplateUtils.getCodeLocation(SamTemplateUtils.kt:101)
    at software.aws.toolkits.jetbrains.services.lambda.LambdaBuilder.defaultPathMappings(LambdaBuilder.kt:85)
    at software.aws.toolkits.jetbrains.services.lambda.execution.sam.SamRunningState.createPathMappings(SamRunningState.kt:85)
    at software.aws.toolkits.jetbrains.services.lambda.execution.sam.SamRunningState.execute(SamRunningState.kt:78)
    at software.aws.toolkits.jetbrains.services.lambda.execution.sam.SamInvokeRunner.execute(SamInvokeRunner.kt:73)
    at com.intellij.execution.runners.AsyncProgramRunner$execute$1.invoke(GenericProgramRunner.kt:48)
    at com.intellij.execution.runners.AsyncProgramRunner$execute$1.invoke(GenericProgramRunner.kt:43)
    at com.intellij.execution.impl.ExecutionManagerImpl$startRunProfile$1.invoke(ExecutionManagerImpl.kt:173)
    at com.intellij.execution.impl.ExecutionManagerImpl$startRunProfile$1.invoke(ExecutionManagerImpl.kt:72)
    at com.intellij.execution.impl.ExecutionManagerImpl$doStartRunProfile$startRunnable$1.run(ExecutionManagerImpl.kt:234)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
    at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
    at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:513)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:75)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:118)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:42)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:779)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:749)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:898)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:439)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:791)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:438)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
    at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:604)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:436)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:484)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
rli commented 1 year ago

It actually looks like we've never supported this properly for AWS::Lambda::Function.

We're expecting Code to point to a file path, which doesn't make sense. The following should be enough to start a debug session against your sample project

  dummy:
    Type: AWS::Lambda::Function
    Properties:
      Code: lambda_handler
      Handler: handler.main
      Runtime: python3.9
...