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]Error Processing handlebars [TypeError: Cannot read property 'find' of undefined] #940

Closed
danielp37 opened this issue Feb 2, 2021 · 5 comments

Comments

@danielp37
Copy link

Describe the bug
We are trying to generate release notes for stage and this is the first time that this stage has been deployed. When it runs it ends up failing with:
##[error]Error Processing handlebars [TypeError: Cannot read property 'find' of undefined]

We are running "Generate Release Notes (Crossplatform)" version 3.43.11

We've run the same step in a prior stage without error (the step is in a Task Group so the template is the same between stages). The work items would be different for this stage because it hasn't been successfully run yet.

To Reproduce

Expected behavior
I'm expecting it to generate release notes similar to what it does for other stages.
Here is the template we are using:
template.txt

Logs
GenerateReleaseNotes.Log

What is the issue see:

  • Azure DevOps Services (VSTS)
@danielp37 danielp37 added the bug label Feb 2, 2021
@rfennell
Copy link
Owner

rfennell commented Feb 3, 2021

The log shows that all the data discovery stages have run

2021-02-02T23:31:32.2882557Z Total Builds: [1]
2021-02-02T23:31:32.2882972Z Total Commits: [6]
2021-02-02T23:31:32.2883354Z Total Workitems: [3]
2021-02-02T23:31:32.2883809Z Total Related Workitems (Parent/Children): [5]
2021-02-02T23:31:32.2884311Z Total Release Tests: [414]
2021-02-02T23:31:32.2884704Z Total Tests: [965]
2021-02-02T23:31:32.2885116Z Total Pull Requests: [2]
2021-02-02T23:31:32.2885545Z Total Indirect Pull Requests: [0]
2021-02-02T23:31:32.3338060Z ##[debug]Using template mode InLine

It is then loading the template OK

2021-02-02T23:31:32.3338705Z Using in-line template
2021-02-02T23:31:32.3339315Z ##[debug]Loading handlebar template
2021-02-02T23:31:32.3341379Z ##[debug]Processing template
2021-02-02T23:31:32.3342098Z ##[debug]  WI: 3
2021-02-02T23:31:32.3343227Z ##[debug]  CS: 6
2021-02-02T23:31:32.3343868Z ##[debug]  PR: 2
2021-02-02T23:31:32.3344492Z ##[debug]  Builds: 1
2021-02-02T23:31:32.3345151Z ##[debug]  Global Tests: 965
2021-02-02T23:31:32.3345832Z ##[debug]  Release Tests: 414
2021-02-02T23:31:32.3346536Z ##[debug]  Related WI: 5
2021-02-02T23:31:32.3347171Z ##[debug]  Indirect PR: 0
2021-02-02T23:31:32.3347860Z ##[debug]Processing handlebar template
2021-02-02T23:31:32.4442010Z Loading handlebars-helpers extension
2021-02-02T23:31:33.1874786Z ##[debug]No custom Handlebars code to process

But then is failing when handlebars tries to process the template

2021-02-02T23:31:33.3074726Z ##[error]Error Processing handlebars [TypeError: Cannot read property 'find' of undefined]
2021-02-02T23:31:33.3077775Z ##[debug]Processed: ##vso[task.issue type=error;]Error Processing handlebars [TypeError: Cannot read property 'find' of undefined] 

From past experience issues with find can be related to bad data in loops.

As the issue appears to be in the output production, I would suggest simplifying the template until there is no error then build it back up again. Unfortunately I have no tools to help to give more insight to what is occurring during processing.

However, what might be use to speed this process is to use my command line runner for this task, check it out here. You can then re-run a build on demand after pulling the config values from the log you provided to in this issue

@rfennell rfennell self-assigned this Feb 3, 2021
@rfennell rfennell removed their assignment Feb 3, 2021
@danielp37
Copy link
Author

I will see if I can get the command line runner running and see if I can identify where in the template it is failing. Thanks for your suggestion.

@danielp37
Copy link
Author

After running this through the command line runner, I was able to narrow this down to this:

{{#forEach this.workItems}}
{{#forEach this.relations}}
{{#if (contains this.attributes.name 'Parent')}}
{{#with (lookup_a_work_item ../../relatedWorkItems this.url)}}
{{#forEach this.relations}}
{{#if (contains this.attributes.name 'Parent')}}

This second lookup_a_work_item is getting a null array from the ../../relatedWorkItems
{{#with (lookup_a_work_item ../../relatedWorkItems this.url)}}
{{/with}}

{{/if}}
{{/forEach}}
{{/with}}
{{/if}}
{{/forEach}}
{{/if}}
{{/forEach}}

We are trying to be able to report up to two parents (ie US -> Feature -> Epic or Task -> US -> Feature). The second #with is in the context of the first relatedWorkItem (I think). Is what I want to do possible?

Thanks,

Dan

@rfennell
Copy link
Owner

rfennell commented Feb 4, 2021

It could be the wrong number of ../ in the ../../relatedWorkItems. The relatedWorkItems is at the root level so you have to step up through the loop this references.

If you have the test harness running I would suggest experimenting adding and removing ../ blocks

@github-actions
Copy link

github-actions bot commented Mar 7, 2021

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the Stale label Mar 7, 2021
This was referenced Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants