Issue and IssueComment attachments field is always an empty Set when accessed in a workflow?

What gives?

How am I supposed to include links to attachments when sending issue activity notifications to an external service?

0
3 comments

Hi Hjvt,

If the issue/issue comment contains attachments, the attachments property shouldn't return an empty set. Can you please share the full workflow code you use to query the attachments? It'll help us investigate the issue further.

Also, can you please share which YouTrack version you use?

0

We are on Build 2025.1.69895
And this seems to be the minimum reproducer:

const entities = require('@jetbrains/youtrack-scripting-api/entities');
exports.rule = entities.Issue.action({
 title: 'Resync',
 userInput: null,
 command: 'resync',
 guard: (ctx) => {
   return true;
 },
 action: (ctx) => {
   const issue = ctx.issue;
   issue.comments.forEach((comment) => {
     console.log(JSON.stringify(comment.attachments));
   });
 },
 requirements: {}
});
0

JSON.stringify converts Set objects to {}, so the result is expected. You mentioned sending links to attachments to the external service, so it makes sense to iterate through the comment.attachments set and build a special JavaScript object consisting of fileUrl properties (and possibly other necessary data). Alternatively, you can try converting a set into an array.

0

Please sign in to leave a comment.