fix: return empty activity channels when no subprojects are found - #4246
Merged
Conversation
…ubprojects Avoid invalid `segmentId IN ()` SQL when project scope expands to zero active subprojects after moving expansion out of middleware. Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Contributor
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a backend 500 on GET /activity/channel by handling the “segment expansion yields zero subprojects” case safely, avoiding invalid SQL like segmentId IN () and returning an empty channel map instead.
Changes:
- Return
{}fromActivityService.findActivityChannels()whengetSegmentSubprojectIds(...)returns no IDs. - Add a defensive early return
{}inSegmentRepository.fetchTenantActivityChannels(...)when called with an emptysegmentIdsarray.
Metadata note (repo workflow):
- The PR title does not include a JIRA key in the required format
type: description (CM-XXX)(see.claude/rules/commit-workflow.md:52-56). CI won’t fail (neutral check), but repo policy expects it.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| backend/src/services/activityService.ts | Short-circuits /activity/channel to return {} when segment expansion is empty, preventing downstream invalid queries. |
| backend/src/database/repositories/segmentRepository.ts | Adds a guard clause to avoid generating invalid IN () SQL when segmentIds is empty. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Fixes a 500 on
GET /activity/channelafter moving segment expansion out of middleware. When the current project scope expands to zero active subprojects, the handler now returns an empty channel map instead of running SQL withsegmentId IN ().Changes
activityService.findActivityChannels— return{}whengetSegmentSubprojectIdsyields no IDs (same pattern asactivity/queryfor empty expansion).segmentRepository.fetchTenantActivityChannels— early return{}whensegmentIdsis empty, so no caller can generate invalidIN ()SQL.Context
With the middleware refactor,
/activity/channelexpands segments at the call site instead of relying on pre-expandedcurrentSegmentsor the old all-tenant-subprojects fallback. Expansion can legitimately be empty (e.g. project group with no active subprojects, or segment context not ready). Activities already handled this; channels did not.