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

PLU-393: Variables: keys with . may be single key or nested path #831

Merged
merged 7 commits into from
Dec 24, 2024

Conversation

kevinkim-ogp
Copy link
Contributor

@kevinkim-ogp kevinkim-ogp commented Dec 20, 2024

TL;DR

New MyInfo Child fields from FormSG returns data with . as part of the key (e.g., child.birthdate).

Libraries like lodash.get treat . as a path separator for nested properties (e.g., accessing child.birthdate), leading to incorrect value retrieval or failure.

What changed?

  • Replaced the . in keys with _ to avoid issues with obtaining values.

How to test?

  1. Run the test suite to verify all scenarios pass
  2. Test with actual FormSG fields from MyInfo Child

Why make this change?

The standard lodash.get function doesn't properly handle cases where object keys contain dots, leading to incorrect property access. This implementation provides more accurate property resolution.

Copy link
Contributor Author

kevinkim-ogp commented Dec 20, 2024

@kevinkim-ogp kevinkim-ogp changed the title fix: formsg var keys with . may be single key PLU-Formatter: FormSG MyInfo Child Birth date in dd/MM/yyyy format Dec 20, 2024
@kevinkim-ogp kevinkim-ogp changed the title PLU-Formatter: FormSG MyInfo Child Birth date in dd/MM/yyyy format PLU-394: fix: FormSG MyInfo Child Birth date in dd/MM/yyyy format Dec 20, 2024
Copy link

linear bot commented Dec 20, 2024

@kevinkim-ogp kevinkim-ogp changed the title PLU-394: fix: FormSG MyInfo Child Birth date in dd/MM/yyyy format PLU-393: Variables: keys with . may be single key or nested path Dec 20, 2024
Copy link

linear bot commented Dec 20, 2024

@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Dec 20, 2024

Datadog Report

Branch report: fix/formsg/var-single-keys-with-dot
Commit report: da9ac46
Test service: plumber

✅ 0 Failed, 732 Passed, 0 Skipped, 2m 9.01s Total Time
➡️ Test Sessions change in coverage: 1 no change

@kevinkim-ogp kevinkim-ogp marked this pull request as ready for review December 20, 2024 01:32
@kevinkim-ogp kevinkim-ogp requested a review from a team as a code owner December 20, 2024 01:32
@pregnantboy pregnantboy force-pushed the fix/formsg/var-single-keys-with-dot branch from 15f8281 to da9ac46 Compare December 23, 2024 09:03
@pregnantboy pregnantboy merged commit d3b6611 into develop-v2 Dec 24, 2024
4 checks passed
@pregnantboy pregnantboy deleted the fix/formsg/var-single-keys-with-dot branch December 24, 2024 04:37
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

Successfully merging this pull request may close these issues.

2 participants