Skip to content
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

Error [UriParameterError]: Expected uri parameter to have length >= 1 #2500

Open
McCo0L opened this issue Nov 3, 2022 · 0 comments
Open

Comments

@McCo0L
Copy link

McCo0L commented Nov 3, 2022

Issue Summary

Trying to deploy a nextjs application modifying an existing Cloudfront distribution

Actual behavior

Deployment doesn't finish with error message:

  DEBUG ─ Updating CloudFront distribution of ID XXXXXXXXXXX.

  error:
  Error [UriParameterError]: Expected uri parameter to have length >= 1, but found "" for params.Bucket
    at ParamValidator.fail (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/param_validator.js:50:37)
    at ParamValidator.validateUri (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/param_validator.js:166:14)
    at ParamValidator.validateString (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/param_validator.js:159:12)
    at ParamValidator.validateScalar (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/param_validator.js:131:21)
    at ParamValidator.validateMember (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/param_validator.js:95:21)
    at ParamValidator.validateStructure (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/param_validator.js:76:14)
    at ParamValidator.validateMember (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/param_validator.js:89:21)
    at ParamValidator.validate (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/param_validator.js:34:10)
    at Request.VALIDATE_PARAMETERS (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/event_listeners.js:132:42)
    at Request.callListeners (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at callNextListener (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/sequential_executor.js:96:12)
    at ~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/event_listeners.js:86:9
    at finish (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/config.js:396:7)
    at ~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/config.js:414:9
    at SharedIniFileCredentials.get (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/credentials.js:127:7)
    at getAsyncCredentials (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/config.js:408:24)
    at Config.getCredentials (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/config.js:428:9)
    at Request.VALIDATE_CREDENTIALS (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/event_listeners.js:81:26)
    at Request.callListeners (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/sequential_executor.js:102:18)
    at Request.emit (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/request.js:686:14)
    at Request.transition (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at Request.runTo (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/request.js:406:15)
    at ~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/request.js:795:12
    at new Promise (<anonymous>)
    at Request.promise (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/node_modules/aws-sdk/lib/request.js:781:12)
    at exports.default (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/dist/grantCloudFrontBucketAccess.js:24:10)
    at ~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/dist/index.js:19:97
    at Array.map (<anonymous>)
    at updateBucketsPolicies (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/dist/index.js:19:35)
    at updateCloudFrontDistribution (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/dist/index.js:186:15)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async CloudFront.default (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/aws-cloudfront/dist/component.js:60:30)
    at async NextjsComponent.deploy (~/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/serverless-component/dist/component.js:576:35)
    at async fn (~/.nvm/versions/node/v16.1.0/lib/node_modules/serverless/node_modules/@serverless/template/utils.js:280:41)
    at async Promise.all (index 0)
    at async executeGraph (~/.nvm/versions/node/v16.1.0/lib/node_modules/serverless/node_modules/@serverless/template/utils.js:294:3)
    at async Template.default (~/.nvm/versions/node/v16.1.0/lib/node_modules/serverless/node_modules/@serverless/template/serverless.js:67:38)
    at async Object.runComponents (~/.nvm/versions/node/v16.1.0/lib/node_modules/serverless/node_modules/@serverless/cli/src/index.js:222:17) {
  code: 'UriParameterError',
  time: 2022-11-03T13:07:44.613Z
}

  319s › nextApp › UriParameterError: Expected uri parameter to have length >= 1, but found "" for params.Bucket

Expected behavior

Cloudfront distribution modified with alll behaviors and origins.

Steps to reproduce

Create a Cloudfront distribution with default origin and behavior
run sls --debug with serverless.yml file below

Screenshots/Code/Configuration/Logs

serverless.yml

name: FE

nextApp:
  component: "@sls-next/[email protected]"
  inputs:
    build:
      env:
        BASE_FE_URL: "https://stage.xxxxxxxxxxxxxx.com"
    memory: 1024
    bucketName: "XXXXXXXXXXXXX-XXXXXXXXXXX-app"
    bucketRegion: "us-west-2"
    cloudfront:
      distributionId: XXXXXXXXXX
      aliases: ["stage.xxxxxxxxxxxxxx.com"]
      defaults:
        forward:
          cookies: ["Auth"]
          headers: ["Authorization"]
      _next/data/*:
        forward:
          cookies: ["Auth"]
          headers: ["Authorization"]
      _next/image*:
        forward:
          cookies: ["Auth"]
          headers: ["Authorization"]
      _next/static/*:
        forward:
          cookies: ["Auth"]
          headers: ["Authorization"]
      static/*:
        forward:
          cookies: ["Auth"]
          headers: ["Authorization"]
      origins:
        - url: https://xxxxxxxxxxxxxxxxxx.us-west-2.elb.amazonaws.com
          protocolPolicy: https-only
          pathPatterns:
            sam/admin/*:
              minTTL: 0
              maxTTL: 86400
              defaultTTL: 60
              allowedHttpMethods:
                ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]
              forward: # optional
                headers: ["Host", "Referer"]
                cookies: "all"
                queryString: true
            scm/admin/*:
              minTTL: 0
              maxTTL: 86400
              defaultTTL: 60
              allowedHttpMethods:
                ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]
              forward: # optional
                headers: ["Host"]
                cookies: "all"
                queryString: true
        - url: https://xxxxxxxxxxxxxxxxxx.us-west-2.elb.amazonaws.com
          protocolPolicy: https-only
          pathPatterns:
            sam/*:
              minTTL: 0
              maxTTL: 86400
              defaultTTL: 60
              allowedHttpMethods:
                ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]
              forward: # optional
                headers: ["Host", "Referer"]
                cookies: "all"
                queryString: true
            scm/*:
              minTTL: 0
              maxTTL: 86400
              defaultTTL: 60
              allowedHttpMethods:
                ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]
              forward: # optional
                headers: ["Host", "Referer"]
                cookies: "all"
                queryString: true
        - url: https://xxxxxxxxxxxxxx.lambda-url.us-west-2.on.aws
          protocolPolicy: https-only
          pathPatterns:
            facade/*:
              minTTL: 0
              maxTTL: 86400
              defaultTTL: 60
              allowedHttpMethods:
                ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]
              forward: # optional
                headers: "none"
                cookies: "all"
                queryString: true

Versions

  • OS/Environment: Ubuntu linux 20.04
  • @sls-next/serverless-component version: 3.7.0
  • Next.js version: 12.3.1

Additional context

Preexistent Cloudfront distribution with default behavior and origin

Checklist

  • [ x] You have reviewed the README and FAQs, which answers several common questions.
  • [x ] You have reviewed our DEBUGGING wiki and have tried your best to include complete information and reproduction steps (including your configuration) as is possible. As there is only one maintainer (who maintains this in his free time) and thus very limited resources, if you have time, please try to debug the issue a bit yourself if possible.
  • [x ] You have first tried using the most recent latest @sls-next/serverless-component 3.7.0, which may have already fixed your issue or implemented the feature you are trying to use. Note that the old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant