Skip to content

fix: list workspaces should exclude deleted workspaces#328

Merged
think-in-universe merged 1 commit intomainfrom
fix/list-active-workspaces
Jan 5, 2026
Merged

fix: list workspaces should exclude deleted workspaces#328
think-in-universe merged 1 commit intomainfrom
fix/list-active-workspaces

Conversation

@think-in-universe
Copy link
Contributor

@think-in-universe think-in-universe commented Jan 4, 2026

Copilot AI review requested due to automatic review settings January 4, 2026 08:26
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @think-in-universe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a crucial fix to the workspace listing mechanism. Previously, the system might have returned both active and inactive workspaces, leading to potentially irrelevant data being displayed. The change ensures that all workspace listings are accurately filtered to only include currently active workspaces, thereby improving data integrity and user experience by presenting only relevant information.

Highlights

  • Database Query Modification: The SQL query responsible for listing workspaces has been updated to include a filter for active workspaces only.
  • Data Filtering: The list workspaces functionality will now exclusively return workspaces where the is_active flag is set to true.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@claude
Copy link

claude bot commented Jan 4, 2026

Code Review

This is a small but important fix that ensures only active workspaces are returned when listing workspaces for an organization.

✅ No Critical Issues Found

The change correctly adds the is_active = true filter to the workspace listing query, which aligns with other methods in the repository (e.g., list_by_user at line 249 already has this filter).

Minor Observation

The fix is consistent with the existing pattern in the codebase. I verified that the list_by_user method on line 249 already includes AND is_active = true, so this change brings list_workspaces_for_organization_with_pagination into alignment with that pattern.

Production Safety

  • Backward compatibility: ✅ This is a filtering change, not a breaking change. Clients will simply see fewer workspaces (only active ones).
  • Rolling deployment: ✅ Safe - old versions may show inactive workspaces temporarily, but this won't cause errors.
  • Performance: ✅ Query should use existing indexes on (organization_id, is_active) if present.

Overall Assessment: ✅ APPROVED

The change is correct, minimal, and follows existing patterns in the codebase.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where the list_by_organization_paginated method was returning all workspaces (both active and inactive) instead of only active ones. The fix adds the AND is_active = true filter to the SQL query to match the behavior of other workspace listing methods.

Key Changes

  • Added AND is_active = true filter to the paginated workspace listing query to ensure only active workspaces are returned

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes an issue where listing workspaces with pagination would include inactive workspaces. The change adds an AND is_active = true filter to the SQL query, making it consistent with other workspace-listing functions. I've included one suggestion to improve maintainability by replacing SELECT * with an explicit column list. This is a good practice that could be applied to other queries in this file for consistency.

client
.query(
&format!("SELECT * FROM workspaces WHERE organization_id = $1 ORDER BY {order_by_column} {order_dir} LIMIT $2 OFFSET $3"),
&format!("SELECT * FROM workspaces WHERE organization_id = $1 AND is_active = true ORDER BY {order_by_column} {order_dir} LIMIT $2 OFFSET $3"),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better maintainability and to avoid fetching unnecessary data, it's a good practice to specify columns explicitly instead of using SELECT *. This makes the query's dependencies on the table schema clear and can prevent issues if the table is altered (e.g., adding large columns that would be fetched unnecessarily).

Suggested change
&format!("SELECT * FROM workspaces WHERE organization_id = $1 AND is_active = true ORDER BY {order_by_column} {order_dir} LIMIT $2 OFFSET $3"),
&format("SELECT id, name, display_name, description, organization_id, created_by_user_id, created_at, updated_at, is_active, settings FROM workspaces WHERE organization_id = $1 AND is_active = true ORDER BY {order_by_column} {order_dir} LIMIT $2 OFFSET $3"),

@think-in-universe think-in-universe changed the title fix: list workspaces should only return active workspaces fix: list workspaces should only return workspaces that are not deleted Jan 4, 2026
@think-in-universe think-in-universe changed the title fix: list workspaces should only return workspaces that are not deleted fix: list workspaces should exclude deleted workspaces Jan 4, 2026
@think-in-universe
Copy link
Contributor Author

This has been temporarily fixed in frontend in this PR: https://github.com/nearai/nearai-cloud-ui/pull/149

@think-in-universe think-in-universe merged commit db4417f into main Jan 5, 2026
9 checks passed
@think-in-universe think-in-universe deleted the fix/list-active-workspaces branch January 5, 2026 15:07
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.

Bug: GET /v1/organizations/{org_id}/workspaces Inconsistent Response Data

3 participants