aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
184 stars 62 forks source link

empty space in client id throws cryptic error #2134

Open ykethan opened 3 weeks ago

ykethan commented 3 weeks ago

Environment information

System:
  OS: macOS 14.7
  CPU: (8) arm64 Apple M1
  Memory: 145.33 MB / 16.00 GB
  Shell: /opt/homebrew/bin/fish
Binaries:
  Node: 20.11.1 - ~/.local/share/nvm/v20.11.1/bin/node
  Yarn: 1.22.21 - ~/.local/share/nvm/v20.11.1/bin/yarn
  npm: 10.8.2 - ~/.local/share/nvm/v20.11.1/bin/npm
  pnpm: 9.10.0 - ~/Library/pnpm/pnpm
NPM Packages:
  @aws-amplify/auth-construct: 1.3.1
  @aws-amplify/backend: 1.5.0
  @aws-amplify/backend-auth: 1.2.0
  @aws-amplify/backend-cli: 1.2.9
  @aws-amplify/backend-data: 1.1.4
  @aws-amplify/backend-deployer: 1.1.5
  @aws-amplify/backend-function: 1.7.0
  @aws-amplify/backend-output-schemas: 1.3.0
  @aws-amplify/backend-output-storage: 1.1.2
  @aws-amplify/backend-secret: 1.1.4
  @aws-amplify/backend-storage: 1.2.1
  @aws-amplify/cli-core: 1.1.3
  @aws-amplify/client-config: 1.4.0
  @aws-amplify/deployed-backend-client: 1.4.1
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.8
  @aws-amplify/platform-core: 1.1.0
  @aws-amplify/plugin-types: 1.3.0
  @aws-amplify/sandbox: 1.2.3
  @aws-amplify/schema-generator: 1.2.4
  aws-amplify: 6.6.5
  aws-cdk: 2.162.1
  aws-cdk-lib: 2.162.1
  typescript: 5.6.3
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Describe the bug

error thrown

validation error detected: Value '{accounts.google.com=************-********************************.apps.googleusercontent.com, graph.facebook.com=**************** }' at 'supportedLoginProviders' failed to satisfy constraint: Map value must satisfy constraint: [Member must have length less than or equal to 128, Member must have length greater than or equal to 1, Member must satisfy regular expression pattern: [\w.;_/-]+] (Service: CognitoIdentity, Status Code: 400,

if the clientID contains a space the deployment fails with the error message which kind of says the length is greater than 128

Reproduction steps

create auth resource with a space in clientID secret. eg(12345)

import { defineAuth } from "@aws-amplify/backend";

/**
 * Define and configure your auth resource
 * @see https://docs.amplify.aws/gen2/build-a-backend/auth
 */
export const auth = defineAuth({
  loginWith: {
    email: true,
    externalProviders: {
      google: {
        clientId: secret("GOOGLE_CLIENT_ID"),
        clientSecret: secret("GOOGLE_CLIENT_SECRET"),
        scopes: ["email", "profile", "openid"],
        attributeMapping: {
          email: "email",
          familyName: "family_name",
          givenName: "given_name",
          fullname: "name",
        },
      },
      callbackUrls: ["http://localhost:3000"],
      logoutUrls: ["http://localhost:3000/auth/login"],
    },
  },
});