Skip to content

Bug: Error publishing serverless application (Missing required parameter in input: "ApplicationId") #6566

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

Closed
jcsobrino opened this issue Jan 17, 2024 · 3 comments
Labels
area/publish sam publish command blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. stage/bug-repro The issue/bug needs to be reproduced

Comments

@jcsobrino
Copy link

Description:

SAM CLI publish command fails updating an already existing serverless application. Diving into the code, we have observed SAM CLI firstly tries to create the application. If it already exists, it extracts from the error message the Application ID. Then, it updates the application with that Application ID.

However, in our case, AWS returns this error message:

An error occurred (ConflictException) when calling the CreateApplication operation: Application with name <application-name> already exists

instead of something like this:

An error occurred (ConflictException) when calling the CreateApplication operation: Application with id arn:aws:serverlessrepo:<region>:<account-id>:applications/<application-name> already exists

So, the regular expression does not match with the error message, it cannot extract the Application ID and the updating operation fails.

Steps to reproduce:

We execute these commands in a GitHub action, but the result it is the same from the shell in a local computer. The error raises in the last command.

sam validate
sam build
sam package --s3-bucket serverless-applications --output-template-file packaged.yaml
sam publish --region us-east-1 --template packaged.yaml

Observed result:

Error: Parameter validation failed:
Missing required parameter in input: "ApplicationId"

Expected result:

The serverless application is updated successfully.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: macOS-14.0-arm64-arm-64bit
  2. sam --version: 1.105.0
  3. AWS region: us-east-1
sam --info

{
  "version": "1.105.0",
  "system": {
    "python": "3.11.4",
    "os": "macOS-14.0-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "20.10.16",
    "aws_cdk": "Not available",
    "terraform": "1.4.0"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

@jcsobrino jcsobrino added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Jan 17, 2024
@jcsobrino jcsobrino changed the title Bug: Error updating serverless application (Missing required parameter in input: "ApplicationId") Bug: Error publishing serverless application (Missing required parameter in input: "ApplicationId") Jan 17, 2024
@hnnasit
Copy link
Contributor

hnnasit commented Jan 20, 2024

Hi @jcsobrino, thanks for reporting the issue. I could not reproduce the behavior on my machine. When I try to re-run sam publish to update the application, the create_application API throws the error ConflictException('An error occurred (ConflictException) when calling the CreateApplication operation: Application with id <Application-id> already exists.') . Here's the project I used:
template.yaml

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  sam-app-6566

  Sample SAM Template for sam-app-6566

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 3
    MemorySize: 128

Metadata:
  AWS::ServerlessRepo::Application:
    Author: user
    Description: description
    HomePageUrl: https://github.com/test/test
    Labels:
    - test-app
    LicenseUrl: ./LICENSE.txt
    Name: sam-app-6566
    ReadmeUrl: ./README.md
    SemanticVersion: 0.0.1
    SourceCodeUrl: https://github.com/test/test

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      CodeUri: hello_world/
      Handler: app.lambda_handler
      Runtime: python3.9
      Architectures:
        - x86_64
      Events:
        HelloWorld:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /hello
            Method: get

directory

├── .gitignore
├── LICENSE.txt
├── README.md
├── __init__.py
├── events
│   └── event.json
├── hello_world
│   ├── __init__.py
│   ├── app.py
│   └── requirements.txt
├── packaged.yaml
├── samconfig.toml
├── template.yaml

Can you provide a sample app for us to reproduce the behavior and the steps to update which results in the error? This seems similar to the issue, but would like to reproduce the behavior before marking this as a bug.

@hnnasit hnnasit added blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. area/publish sam publish command stage/bug-repro The issue/bug needs to be reproduced and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Jan 20, 2024
@mildaniel
Copy link
Contributor

Closing due to inactivity. If the issue persists, please open a new issue.

Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/publish sam publish command blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. stage/bug-repro The issue/bug needs to be reproduced
Projects
None yet
Development

No branches or pull requests

3 participants