serverless / serverless/examples

Wrong serverless-http dependency version in the basic express template

Open
#759 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.5k
Forks
4.4k
Avg merge
2h 55m
Merged PRs (30d)
3

Description

Are you certain it's a bug?
  • Yes, it looks like a bug
Is the issue caused by a plugin?
  • It is not a plugin issue
Are you using the latest v3 release?
  • Yes, I'm using the latest v3 release
Is there an existing issue for this?
  • I have searched existing issues, it hasn't been reported yet
Issue description

When installing the latest serverless version
(Framework Core: 3.31.0
Plugin: 6.2.3
SDK: 4.3.2)

And creating a new template by running the serverless command and choosing the "AWS - Node.js - Express API with DynamoDB" template, the following exception occurs when trying to run serverless deploy:
Recoverable error occurred (Invalid character in entity name Line: 0 Column: 176
after a lot of research, chatGPT helped me to find that the serverless-http version which is ^3.1.1 by default is not compatible with serverless version 3.x.
I've changed serverless-http version to ^2.6.1 per its suggestion and my issue has been solved.

Service configuration (serverless.yml) content
service: test
frameworkVersion: '3'

custom:
  profiles:
    dev: dev
    prod: prod
  tableName: 'users_table_${sls:stage}'

provider:
  name: aws
  runtime: nodejs18.x
  profile: ${self:custom.profiles.${sls:stage}}
  iam:
    role:
      statements:
        - Effect: Allow
          Action:
            - dynamodb:Query
            - dynamodb:Scan
            - dynamodb:GetItem
            - dynamodb:PutItem
            - dynamodb:UpdateItem
            - dynamodb:DeleteItem
          Resource:
            - Fn::GetAtt: [ UsersTable, Arn ]
  environment:
    USERS_TABLE: ${self:custom.tableName}

functions:
  api:
    handler: index.handler
    events:
      - httpApi: '*'

resources:
  Resources:
    UsersTable:
      Type: AWS::DynamoDB::Table
      DeletionPolicy: Retain
      Properties:
        AttributeDefinitions:
          - AttributeName: userId
            AttributeType: S
        KeySchema:
          - AttributeName: userId
            KeyType: HASH
        BillingMode: PAY_PER_REQUEST
        TableName: ${self:custom.tableName}
Command name and used flags

serverless deploy --verbose

Command output
Recoverable error occurred (Invalid character in entity name
Line: 0
Column: 176
Environment information
Framework Core: 3.31.0
Plugin: 6.2.3
SDK: 4.3.2

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start with the AWS - Node.js - Express API with DynamoDB basic template and inspect its declared serverless-http dependency. Compare the template version with the reported Serverless Framework 3 environment, update the dependency if appropriate, and verify that serverless deploy --verbose completes without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, express, javascript
Domain
api, backend, cloud, databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.