Skip to content

chore: Adjust Tasks API to support Space tasks#3913

Merged
Rockyy174 merged 13 commits into
operately:mainfrom
Rockyy174:space-tasks-api
Dec 11, 2025
Merged

chore: Adjust Tasks API to support Space tasks#3913
Rockyy174 merged 13 commits into
operately:mainfrom
Rockyy174:space-tasks-api

Conversation

@Rockyy174
Copy link
Copy Markdown
Collaborator

No description provided.

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>
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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>
@Rockyy174 Rockyy174 merged commit 2a3e6d7 into operately:main Dec 11, 2025
2 of 3 checks passed
@Rockyy174 Rockyy174 deleted the space-tasks-api branch December 11, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant