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 while generating Release Notes (TypeError: Cannot read properties of undefined (reading 'length')) #1485

Closed
randywang666 opened this issue Mar 8, 2023 · 4 comments · Fixed by #1486

Comments

@randywang666
Copy link

Azure DevOps Extensions

Generate Release Notes (Node Cross Platform)

Platform

Azure DevOps Services

Azure DevOps Server (TFS) Version

No response

Extension Version

4.5.2

Describe the bug

Hi @rfennell,

My release worked well a few days ago. I didn't change anything. Today, I would like to test it again but threw the below issue.
Could you please help to look at it? Thanks, :)

My template is:

## Build: {{buildDetails.buildNumber}}
* **Branch**: {{replace buildDetails.sourceBranch "refs/heads/" ""}}
* **Tags**: {{buildDetails.tags}}
* **Completed**: {{buildDetails.finishTime}}

## Bugs
| ID & Link | Work Item Title | Priority |
| --- | --- | --- |
{{#forEach this.workItems}}
{{#if (contains (lookup this.fields 'System.WorkItemType') 'Bug')}}
| [{{this.id}}]({{replace this.url "_apis/wit/workItems" "_workitems/edit"}}) | {{lookup this.fields 'System.Title'}} | {{lookup this.fields 'Microsoft.VSTS.Common.Priority'}} |
{{/if}}
{{/forEach}}

Error:
image

Repo Steps

  1. Fixed a bug and commit
  2. Run build
  3. Create a release pipeline with generating Release Notes
  4. See the above error in Description
    ...

Expected Behavior

No response

Logging Information

No response

@rfennell
Copy link
Owner

rfennell commented Mar 8, 2023

The problem only occurs if a pipeline does not generate any published artifacts, I had missed this use case, sorry

The fix is to make sure the containing array is always initialized as an empty array, even if no published artifacts have been found.

I will get a fix out now

@randywang666
Copy link
Author

Hi @rfennell,

Thanks for your fixing. Just test it today. It works well right now. I appreciated that. :)

@SBhavana8
Copy link

Hi @rfennell ,

I am facing same issue as mentioned above.

Below is the error Screenshot:

image

Below is version screenshot:

image

Could you please help us and do the needful.
Thanks in advance.

@rfennell
Copy link
Owner

In your template you will be trying to check the length of an empty array. You need to check if the array exists before performing an operations, something like

{{#if commits}}
There are {{commits.length}} commits
{{end}}

If you can't resolve the problem, log a new issue but make sure you upload

  • the payload.json generated by the task
  • your handlebars template
  • any custom extension you have written

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants