-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(taskAttachment): prevent NPE for deletion of attachments with empty or nonexisting taskId #4817
fix(taskAttachment): prevent NPE for deletion of attachments with empty or nonexisting taskId #4817
Conversation
9a89b08
to
cd73812
Compare
3859a8a
to
997d9a0
Compare
engine/src/test/java/org/camunda/bpm/engine/test/api/task/TaskServiceTest.java
Show resolved
Hide resolved
Attachment attachment = taskService.createAttachment("web page", "", null, "weatherforcast", | ||
"temperatures and more", new ByteArrayInputStream("someContent".getBytes())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested follow up:
Based on my understanding of the issue, I think it would also make sense to look into prohibiting the creation of attachments with empty taskId and null (or empty) processInstanceId. At the moment, this is still allowed because the creation only checks for the taskId not being null. I can open a follow up ticket if you agree that this makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So basically without your fix, we can create a taskless attachment but not delete it, but with your changes, we'll be able to do both, is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, but its more about creating an attachment without taskId and without processInstanceId. My understanding is that it should have either one or the other, but that its fine for it to not have a taskId as long as it still has a processInstanceId.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joaquinfelici can you let me know about whether to open a follow up for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what we can see in the create attachment documentation, what you say makes sense.
@param processInstanceId - id of a process to use if task id is null
I guess we can create a follow-up ticket to prevent that both taskId
and processInstanceId
are null on creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the follow up ticket
7194bf2
to
00965bc
Compare
…ty or nonexisting taskId related to #3545
00965bc
to
a42a645
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look good! Added some question for clarification and minor suggestions.
Attachment attachment = taskService.createAttachment("web page", "", null, "weatherforcast", | ||
"temperatures and more", new ByteArrayInputStream("someContent".getBytes())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So basically without your fix, we can create a taskless attachment but not delete it, but with your changes, we'll be able to do both, is that correct?
related to #3545
Behaviour is now:
Deleting a task attachment providing an empty taskID:
Deleting a task attachment with an ID of a task that has already been completed:
Note:
Due to this existing implementation, the
NullValueException
thrown in the Delete command will always be returned as anInvalidRequestException
as the API response. I am assuming this is expected behaviour, but lmk if that should be adjusted in any way.