Error in help-desk workflow when adding comment via another workflow

I'm getting an error when adding a comment via a workflow. I'm not sure how to fix it:

Workflow @jetbrains/youtrack-workflow-notify-multiple-unregistered-users reports error: Parameter specified as non-null is null: method jetbrains.youtrack.ring.impl.HubSecurityImpl.hasPermission, parameter project

Here is the code I'm using:

action: function(ctx) {
var issue = ctx.issue;
var user = entities.User.findByLogin('robo_user');
var existingIssue = search.search(issue.project, '{Some filter}', user).first();
if (existingIssue) {
existingIssue.fields['Occurrence count'] += 1;
existingIssue.addComment(issue.description, user); // If I remove this line, there is no error.
}
}

Any ideas?

6 comments
Comment actions Permalink

According to the error message, the error is from another workflow, "@jetbrains/youtrack-workflow-notify-multiple-unregistered-users", from the rule "Send notifications to all unregistered users",  which is triggered when the comment is added to the `existingIssue`. Could you please go to that rule in in-browser editor, open its console and show the complete stack-trace for that rule?

0
Comment actions Permalink

Here is the full stack:

java.lang.IllegalArgumentException: Parameter specified as non-null is null: method jetbrains.youtrack.ring.impl.HubSecurityImpl.hasPermission, parameter project
at jetbrains.youtrack.ring.impl.HubSecurityImpl.hasPermission(HubSecurityImpl.kt)
at jetbrains.charisma.persistence.user.SecurityDelegate.hasPermission(SecurityDelegate.java:120)
at jetbrains.charisma.persistence.user.UserImpl.hasPermission(UserImpl.java:282)
at jetbrains.charisma.persistence.user.UserImpl.hasPermission(UserImpl.java:286)
at jetbrains.charisma.persistent.IssueCommentImpl.isAccessible(IssueCommentImpl.java:299)
at jetbrains.youtrack.persistent.XdIssueComment.isAccessible(XdIssueComment.kt:37)
at jetbrains.youtrack.persistent.XdIssueComment.isAccessible$default(XdIssueComment.kt:36)
at jetbrains.youtrack.workflow.wrappers.IssueCommentsPropertyValueResolverFactory$create$1$get$comments$1.invoke(IssueCommentsPropertyValueResolverFactory.kt:36)
at jetbrains.youtrack.workflow.wrappers.IssueCommentsPropertyValueResolverFactory$create$1$get$comments$1.invoke(IssueCommentsPropertyValueResolverFactory.kt:33)
at kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:109)
at kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:132)
at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:633)
at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(_Sequences.kt:663)
at kotlin.sequences.SequencesKt___SequencesKt$sortedWith$1.iterator(_Sequences.kt:532)
at kotlin.sequences.TransformingSequence$iterator$1.<init>(Sequences.kt:146)
at kotlin.sequences.TransformingSequence.iterator(Sequences.kt:145)
at kotlin.sequences.SequencesKt___SequencesKt$asIterable$$inlined$Iterable$1.iterator(Iterables.kt:101)
at jetbrains.mps.internal.collections.runtime.impl.BasicSequence.iterator(BasicSequence.java:19)
at jetbrains.youtrack.scripts.wrappers.MutableIterableWrapper$ChangedIterable.iterator(MutableIterableWrapper.java:135)
at jetbrains.youtrack.scripts.wrappers.MutableIterableWrapper.iterator(MutableIterableWrapper.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)
at org.mozilla.javascript.gen._jetbrains_youtrack_scripting_api_entities_3038._c_anonymous_8(@jetbrains/youtrack-scripting-api/entities:56)
at org.mozilla.javascript.gen._jetbrains_youtrack_scripting_api_entities_3038.call(@jetbrains/youtrack-scripting-api/entities)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
at org.mozilla.javascript.gen._jetbrains_youtrack_workflow_notify_multiple_unregistered_users_notify_all_unregistered_users_3010._c_createInReplyToMessage_10(@jetbrains/youtrack-workflow-notify-multiple-unregistered-users/notify-all-unregistered-users:87)
at org.mozilla.javascript.gen._jetbrains_youtrack_workflow_notify_multiple_unregistered_users_notify_all_unregistered_users_3010.call(@jetbrains/youtrack-workflow-notify-multiple-unregistered-users/notify-all-unregistered-users)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
at org.mozilla.javascript.gen._jetbrains_youtrack_workflow_notify_multiple_unregistered_users_notify_all_unregistered_users_3010._c_anonymous_2(@jetbrains/youtrack-workflow-notify-multiple-unregistered-users/notify-all-unregistered-users:53)
at org.mozilla.javascript.gen._jetbrains_youtrack_workflow_notify_multiple_unregistered_users_notify_all_unregistered_users_3010.call(@jetbrains/youtrack-workflow-notify-multiple-unregistered-users/notify-all-unregistered-users)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
at org.mozilla.javascript.gen._execution_ctx__3157._c_anonymous_6(_execution_ctx_:82)
at org.mozilla.javascript.gen._execution_ctx__3157.call(_execution_ctx_)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
at org.mozilla.javascript.gen._execution_ctx__3157.call(_execution_ctx_)

 EDIT: In anticipation of a possible question: The robo_user has a Developer role on the project with full rights to change the fields and comments on an issue.

0
Comment actions Permalink

Thank you for the details. I do not see any obvious error in your code, this behaviour looks like a bug for me.

Could you please specify the version and build of YouTrack that you see this behaviour at? It will help me to create a more precise issue.

0
Comment actions Permalink

It's a InCloud YouTrack version 2017.3 - Build 37260 Mon, Oct 30, 2017, 7:50:56 AM UTC

I'll try work around it by disabling the youtrack-workflow-notify-multiple-unregistered-users rule when the user is "robo_user" for now.

Thanks for looking at this.

0
Comment actions Permalink

Great! I look forward to the fix.

0

Please sign in to leave a comment.