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

Missing relations attribute for relatedWorkItems throws TypeError #2003

Closed
Danphillipz opened this issue Oct 22, 2024 · 2 comments · Fixed by #2004
Closed

Missing relations attribute for relatedWorkItems throws TypeError #2003

Danphillipz opened this issue Oct 22, 2024 · 2 comments · Fixed by #2004

Comments

@Danphillipz
Copy link

Azure DevOps Extensions

Generate Release Notes (Node Cross Platform)

Platform

Azure DevOps Services

Azure DevOps Server (TFS) Version

No response

Extension Version

No response

Describe the bug

Ass seen in the attached logging information, due to there being no relations attribute for a specific work item, attempting to access it's length threw an exception.

The function where this occured is here: /~https://github.com/rfennell/AzurePipelines/blob/main/Extensions/XplatGenerateReleaseNotes/XplatGenerateReleaseNotesTask/src/ReleaseNotesFunctions.ts#L794

It looks like the source of the error is on line 803 where we try to access the length property

Repo Steps

In an azure board, I created a Spike user story with no relations.

I then added this to my github commit message using the AB#123 format.

Upon the release note generation step running in my pipeline it threw the error seen in the logs as there was no relations attribute present. While this did not entirely fail the generation, it did results in a partial success of the build

Expected Behavior

If the relations attribute is not present within the WorkItem object it should not attempt to access the .length property. Perhaps some sort of guard clause to check attribute presence before trying to access any nested properties?

Logging Information

Creating the credential handler from the OAUTH token
Getting the current build details
Getting artifacts published by the current build
Getting items associated with only the current build
Get the artifacts consumed by the build
Cannot get extra commit or work item details of the Repository artifact wiki null
Get the file details associated with the commits
Enriched change 6385e1aeea5e8f9c22cf3561a5a4270a603dd1f1 of type GitHub
Enriched with details of 1 files
Enriched change 422c0317f6a23b75075527143d6e4cb2726df927 of type GitHub
Enriched with details of 2 files
Get any test details associated with the build
Get any manual test run details associated with the build
Removing duplicate Commits from master list
Expanding the truncated commit messages...
Expanded truncated commit messages 0
Leaving CS in default order as returned by API
Find any WorkItems linked from GitHub using the AB#123 format
Adding 2 found using AB#123 links in GitHub comments
Removing duplicate WorkItems from master list
Get details of [2] WIs
Getting full details of WI batch from index: [0] to [2]
Adding [2] items
Getting direct parents and children of WorkItems
Looking for parents and children of WI [1293]
The most common runtime reason for the task to fail is due API ECONNRESET issues. To avoid this failing the pipeline these will be treated as warnings and an attempt to generate any release notes possible
TypeError: Cannot read properties of undefined (reading 'length')
Total Builds: [0]
    at /home/vsts/work/_tasks/XplatGenerateReleaseNotes_7b0a5887-75c4-4ade-a915-f92a93c934cb/4.19.2/ReleaseNotesFunctions.js:763:60
    at Generator.next (<anonymous>)
    at /home/vsts/work/_tasks/XplatGenerateReleaseNotes_7b0a5887-75c4-4ade-a915-f92a93c934cb/4.19.2/ReleaseNotesFunctions.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/home/vsts/work/_tasks/XplatGenerateReleaseNotes_7b0a5887-75c4-4ade-a915-f92a93c934cb/4.19.2/ReleaseNotesFunctions.js:4:12)
    at getAllDirectRelatedWorkitems (/home/vsts/work/_tasks/XplatGenerateReleaseNotes_7b0a5887-75c4-4ade-a915-f92a93c934cb/4.19.2/ReleaseNotesFunctions.js:758:12)
    at Object.<anonymous> (/home/vsts/work/_tasks/XplatGenerateReleaseNotes_7b0a5887-75c4-4ade-a915-f92a93c934cb/4.19.2/ReleaseNotesFunctions.js:1636:46)
    at Generator.next (<anonymous>)
    at fulfilled (/home/vsts/work/_tasks/XplatGenerateReleaseNotes_7b0a5887-75c4-4ade-a915-f92a93c934cb/4.19.2/ReleaseNotesFunctions.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Total Commits: [2]
Total Workitems: [2]
Total Related Workitems (Parent/Children): [0]

@rfennell
Copy link
Owner

Just releasing 4.20.2 which has a guard method added

@Danphillipz
Copy link
Author

Amazing, thanks @rfennell!

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.

2 participants