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

Crash when parsing array property when property name contains a dot #82

Closed
andre-aktivconsultancy opened this issue Nov 9, 2023 · 2 comments
Assignees
Labels
duplicate This issue or pull request already exists solved

Comments

@andre-aktivconsultancy
Copy link

Given any of the following values files

foo.bar:
  - bas
  - baz
foo:
  foo.bar:
    - bas
    - baz
foo.bar:
  foo:
    - bas
    - baz

When running readme-generator -r README.md -v values.yaml I expect the values.yaml file to be parsed correctly. However it crashes with:

readme-generator-for-helm/lib/parser.js:147
        _.get(valuesJSON, arrayPrefix).forEach((e) => {
                                      ^

TypeError: Cannot read properties of undefined (reading 'forEach')
    at createValuesObject (/home/andre/workspace/readme-generator-for-helm/lib/parser.js:147:39)
    at getParsedMetadata (/home/andre/workspace/readme-generator-for-helm/index.js:22:24)
    at runReadmeGenerator (/home/andre/workspace/readme-generator-for-helm/index.js:52:28)
    at Object.<anonymous> (/home/andre/workspace/readme-generator-for-helm/bin/index.js:22:1)
    at Module._compile (node:internal/modules/cjs/loader:1253:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

This is caused by passing the value path determined by dot-object to the Lodash get function. Taking this yaml as example:

foo.bar:
  - bas
  - baz

dot-object generates this path: "foo.bar.[0]". This makes Lodash get expect foo to have a property bar.
https://github.com/bitnami-labs/readme-generator-for-helm/blob/24c5ba9220ee9464147d4947c5e0613f8e2487a5/lib/parser.js#L147C55-L147C55

@fmulero
Copy link
Contributor

fmulero commented Nov 10, 2023

Thanks a lot @andre-aktivconsultancy for sharing your finding and such detailed explanation. Would you like to contribute by creating a PR to solve the issue? The Bitnami team will be happy to review it and provide feedback. Here you can find the contributing guidelines.

@fmulero fmulero self-assigned this Nov 10, 2023
@github-actions github-actions bot removed the triage label Dec 4, 2023
@github-actions github-actions bot assigned fmulero and unassigned fmulero Dec 4, 2023
@fmulero
Copy link
Contributor

fmulero commented Mar 12, 2024

Please @andre-aktivconsultancy amend me if I am wrong, but I think this is the same error as reported in #60. I will close this one as duplicated

@fmulero fmulero closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
@fmulero fmulero added the duplicate This issue or pull request already exists label Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists solved
Projects
None yet
Development

No branches or pull requests

2 participants