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

Parce amplfy_outputs.json on IOS #1749

Closed
yegenpres opened this issue Jul 16, 2024 · 6 comments
Closed

Parce amplfy_outputs.json on IOS #1749

yegenpres opened this issue Jul 16, 2024 · 6 comments
Assignees
Labels
amplify_outputs Issue related to generating amplify_outputs for deployed backends auth Issue pertaining to Amplify Auth bug Something isn't working transferred Issue was transferred from another Amplify repository

Comments

@yegenpres
Copy link

yegenpres commented Jul 16, 2024

Describe the bug

It to redefine auth password cfnUserPool.policies like in official documentation.

cfnUserPool.policies = {
  passwordPolicy: {
    minimumLength: 6,
    requireLowercase: false,
    requireNumbers: false,
    requireSymbols: false,
    requireUppercase: false,
  },
};

json looks like this:

   "password_policy": {
      "min_length": 6,
    },

amplify_outputs.json does not contain property name of passwordPolicy object if value is set to false.
Then Swift Coding fail to decode this object as result initAmplify just fails, because official library expects this fields like required.

public struct PasswordPolicy: Codable {
        public let minLength: UInt
        public let requireNumbers: Bool
        public let requireLowercase: Bool
        public let requireUppercase: Bool
        public let requireSymbols: Bool
    }

So we can every boolean value should be set to try or else it just miss in json file, and fail to parse it.

It means that output json should always generate fields with values set to false, or Codable struct accept optional parameters.

Steps To Reproduce

Steps to reproduce the behavior:
1. Go to backend.st
2. add this code: 
const { cfnUserPool } = backend.auth.resources.cfnResources

cfnUserPool.policies = {
  passwordPolicy: {
    minimumLength: 6,
    requireLowercase: true,
    requireNumbers: true,
    requireSymbols: true,
    requireUppercase: true,
    temporaryPasswordValidityDays: 20,
  },
};
3. Run app

Expected behavior

Amplify should init success.

Amplify Framework Version

6.3.7

Amplify Categories

Auth

Dependency manager

Swift PM

Swift version

5.9

CLI version

12.12.4

Xcode version

15.4

Relevant log output

<details>
<summary>Log Messages</summary>

Fail initialize amplify, because missed key in amplify_output.json
INSERT LOG MESSAGES HERE

</details>

Is this a regression?

Yes

Regression additional context

Amplify gen 2

Platforms

iOS

OS Version

iOS 17+

Device

Any iOS device

Specific to simulators

Iphone 15 pro max

Additional context

No response

@harsh62
Copy link
Member

harsh62 commented Jul 16, 2024

Acknowledging the issue. Can you please share the link to the documentation you are following?

@harsh62 harsh62 added auth Issue pertaining to Amplify Auth question Question or confusion about some aspect of the product labels Jul 16, 2024
@harsh62
Copy link
Member

harsh62 commented Jul 16, 2024

Answering my own question. I think you are trying to mention this documentation.
It seems to be a bug in Gen2. Will transfer the issue

@harsh62 harsh62 transferred this issue from aws-amplify/amplify-swift Jul 16, 2024
@josefaidt josefaidt added bug Something isn't working amplify_outputs Issue related to generating amplify_outputs for deployed backends transferred Issue was transferred from another Amplify repository and removed question Question or confusion about some aspect of the product labels Jul 16, 2024
@josefaidt
Copy link
Contributor

Hey @yegenpres 👋 thanks for raising this! I was able to confirm this behavior and have marked this as a bug

@josefaidt
Copy link
Contributor

note: these properties should also be marked as required in the outputs schema for the password policy block https://github.com/aws-amplify/amplify-backend/blob/main/packages/client-config/src/client-config-schema/schema_v1.json#L59-L82

@sobolk sobolk self-assigned this Jul 16, 2024
@yegenpres
Copy link
Author

Answering my own question. I think you are trying to mention this documentation.

It seems to be a bug in Gen2. Will transfer the issue

Yes, this doc.
Please let me know when You will fix it, or give some advice haw to work around

@sobolk
Copy link
Member

sobolk commented Jul 17, 2024

@sobolk sobolk closed this as completed Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
amplify_outputs Issue related to generating amplify_outputs for deployed backends auth Issue pertaining to Amplify Auth bug Something isn't working transferred Issue was transferred from another Amplify repository
Projects
None yet
Development

No branches or pull requests

4 participants