chore: Adjust Tasks API to support Space tasks#3913
Merged
Conversation
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Contributor
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- The various
build_activity_content/1helpers inOperatelyWeb.Api.Tasksusecondwithout a catch‑all clause; if a task somehow lacks both:projectand:space(or those associations aren’t preloaded), these will returnniland silently fail activity creation—consider either pattern‑matching oninputs.typeor adding an explicit fallback error to make this failure mode clearer. - In the task serializer,
get_task_type/1assumes that exactly one ofproject_idorspace_idis nil; if a task is created with both unset (whichvalidate_project_or_group/1allows),condwill fall through and raise—adding an explicit default or assertion here would make misconfigured tasks fail more predictably.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The various `build_activity_content/1` helpers in `OperatelyWeb.Api.Tasks` use `cond` without a catch‑all clause; if a task somehow lacks both `:project` and `:space` (or those associations aren’t preloaded), these will return `nil` and silently fail activity creation—consider either pattern‑matching on `inputs.type` or adding an explicit fallback error to make this failure mode clearer.
- In the task serializer, `get_task_type/1` assumes that exactly one of `project_id` or `space_id` is nil; if a task is created with both unset (which `validate_project_or_group/1` allows), `cond` will fall through and raise—adding an explicit default or assertion here would make misconfigured tasks fail more predictably.
## Individual Comments
### Comment 1
<location> `app/lib/operately_web/api/serializers/task.ex:33-31` </location>
<code_context>
}
end
+
+ defp get_task_type(task) do
+ cond do
+ is_nil(task.project_id) -> "space"
+ is_nil(task.space_id) -> "project"
+ end
+ end
end
</code_context>
<issue_to_address>
**issue (bug_risk):** get_task_type/1 does not handle inconsistent or unexpected project/space combinations, potentially violating non-null GraphQL type
The `cond` handles only the “project only” and “space only” cases and has no `else`. If both `project_id` and `space_id` are `nil`, or both are non-`nil`, this returns `nil` despite the GraphQL schema declaring `field :type, :task_type, null: false`, which can cause runtime serialization errors. Please add an explicit fallback (e.g., raise or default) so we never return `nil` for this field.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
Signed-off-by: Adriano Lazzaretti <lazzaretti136@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.