Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

What is being addressed

The get_*_by_id methods in repository classes return deleted resources, while list methods filter them out. This allows accessing deleted workspaces, workspace services, user resources, and shared services via direct URL after deletion.

How is this addressed

Added deploymentStatus != Status.Deleted filter to all get_by_id queries:

  • WorkspaceRepository.get_workspace_by_id()
  • WorkspaceServiceRepository.get_workspace_service_by_id()
  • UserResourceRepository.get_user_resource_by_id()
  • SharedServiceRepository.get_shared_service_by_id()

Query pattern:

query += ' AND c.deploymentStatus != @deletedStatus'
parameters.append({'name': '@deletedStatus', 'value': Status.Deleted})

Updated unit tests to verify deleted resources raise EntityDoesNotExist.

Updated CHANGELOG.md with bug fix entry and component version update.

Incremented API version from 0.25.6 to 0.25.7.

Original prompt

This section details on the original issue you should resolve

<issue_title>Deleted workspaces are still accessible via URL</issue_title>
<issue_description>Describe the bug
workspaces are still accessible via their URL after they are deleted
See also #4307 as this functionality may be required

Steps to reproduce

  1. Create a workspace
  2. copy the url
  3. delete the workspace
  4. re-visit the url

Azure TRE release version (e.g. v0.14.0 or main):
main
Deployed Azure TRE components - click the (i) in the UI:

Azure TRE
UI Version:
0.8.17
API Version:
0.25.2</issue_description>

Comments on the Issue (you are @copilot in this section)

@marrobi Ok, it looks like the get `X_by_id` methods are not filtering deleted out, but the list methods are.
Entity Type List Endpoint (filters deleted?) Get-by-ID (filters deleted?)
Workspace Yes No
Workspace Service Yes No
User Resource Yes No
Shared Service Yes No

So need something like:

async def get_workspace_by_id(self, workspace_id: str) -> Workspace:
    query = 'SELECT * FROM c WHERE c.resourceType = @resourceType AND c.id = @workspaceId AND c.deploymentStatus != @deletedStatus'
    parameters = [
        {'name': '@resourceType', 'value': ResourceType.Workspace},
        {'name': '@workspaceId', 'value': str(workspace_id)},
        {'name': '@deletedStatus', 'value': Status.Deleted}
    ]
    workspaces = await self.query(query=query, parameters=parameters)
    if not workspaces:
        raise EntityDoesNotExist
    return parse_obj_as(Workspace, workspaces[0])

There should also be unit tests to verify this.

@tamirkamara @jonnyry welcome your view on this, I don't think these endpoints should return deleted resources?

@jonnyry @marrobi Hmm I can't think of a reason why the current codebase would need Get-by-ID methods to return deleted entities.

There might be some possible use cases in future, perhaps an audit trail or those outlined in #4307, but for those cases you could an additional optional parameter to include deleted resources (with a default of false).</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Updated get_workspace_by_id to exclude deleted workspaces
- Updated get_workspace_service_by_id to exclude deleted services
- Updated get_user_resource_by_id to exclude deleted user resources
- Updated get_shared_service_by_id to exclude deleted shared services
- Added/updated unit tests to verify deleted resources are filtered
- Updated CHANGELOG.md with bug fix entry

Co-authored-by: marrobi <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix access to deleted workspaces via URL Filter deleted resources in get_by_id repository methods Dec 18, 2025
@github-actions
Copy link

github-actions bot commented Dec 18, 2025

Unit Test Results

668 tests   668 ✅  7s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit 71593ab.

♻️ This comment has been updated with latest results.

Copilot AI requested a review from marrobi December 18, 2025 13:03
@marrobi marrobi marked this pull request as ready for review December 18, 2025 13:03
@marrobi marrobi requested a review from a team as a code owner December 18, 2025 13:03
@marrobi
Copy link
Member

marrobi commented Dec 18, 2025

@copilot update the API version

Incremented API version from 0.25.6 to 0.25.7 for bug fix release.
Added version update entry to CHANGELOG.md COMPONENTS section.

Co-authored-by: marrobi <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 18, 2025

@copilot update the API version

Updated API version to 0.25.7 in commit 2e4d7e8

@JC-wk
Copy link
Collaborator

JC-wk commented Jan 8, 2026

api version will need upping again

Copy link
Collaborator

@JC-wk JC-wk left a comment

Choose a reason for hiding this comment

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

I have tested this and deleted workspaces are no longer visible @marrobi

@marrobi
Copy link
Member

marrobi commented Jan 12, 2026

@tamirkamara are you able to look at this one? Thanks.

@github-actions
Copy link

🤖 pr-bot 🤖

⚠️ The specified SHA f645fff is not the latest commit on the PR. Please validate the latest commit and re-run /test

(in response to this comment from @marrobi)

@marrobi
Copy link
Member

marrobi commented Jan 13, 2026

/test-extended a3fc372

@github-actions
Copy link

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/20956292168 (with refid 95c03b79)

(in response to this comment from @marrobi)

@marrobi marrobi enabled auto-merge (squash) January 13, 2026 12:40
@github-actions
Copy link

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/20956292168 (with refid 95c03b79)

(in response to this comment from @marrobi)

@marrobi
Copy link
Member

marrobi commented Jan 14, 2026

/test-extended a3fc372

@github-actions
Copy link

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/20989307837 (with refid 95c03b79)

(in response to this comment from @marrobi)

1 similar comment
@github-actions
Copy link

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/20989307837 (with refid 95c03b79)

(in response to this comment from @marrobi)

@marrobi
Copy link
Member

marrobi commented Jan 14, 2026

/test-destroy-env

@github-actions
Copy link

Destroying branch test environment (RG: rg-tre0a48c21f)... (run: https://github.com/microsoft/AzureTRE/actions/runs/20994544513)

@github-actions
Copy link

Branch test environment destroy complete (RG: rg-tre0a48c21f)

@github-actions
Copy link

Destroying PR test environment (RG: rg-tre95c03b79)... (run: https://github.com/microsoft/AzureTRE/actions/runs/20994544513)

@github-actions
Copy link

PR test environment destroy complete (RG: rg-tre95c03b79)

@marrobi
Copy link
Member

marrobi commented Jan 14, 2026

/test-extended f4febb0

@github-actions
Copy link

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/20995310765 (with refid 95c03b79)

(in response to this comment from @marrobi)

2 similar comments
@github-actions
Copy link

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/20995310765 (with refid 95c03b79)

(in response to this comment from @marrobi)

@github-actions
Copy link

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/20995310765 (with refid 95c03b79)

(in response to this comment from @marrobi)

@tamirkamara
Copy link
Collaborator

/test-destroy-env

@github-actions
Copy link

Destroying branch test environment (RG: rg-tre0a48c21f)... (run: https://github.com/microsoft/AzureTRE/actions/runs/21032942381)

@github-actions
Copy link

Branch test environment destroy complete (RG: rg-tre0a48c21f)

@github-actions
Copy link

Destroying PR test environment (RG: rg-tre95c03b79)... (run: https://github.com/microsoft/AzureTRE/actions/runs/21032942381)

@github-actions
Copy link

PR test environment destroy complete (RG: rg-tre95c03b79)

@tamirkamara
Copy link
Collaborator

/test-extended 71593ab

@github-actions
Copy link

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/21108169623 (with refid 95c03b79)

(in response to this comment from @tamirkamara)

Copy link
Collaborator

@tamirkamara tamirkamara left a comment

Choose a reason for hiding this comment

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

@marrobi I believe something not right here as the E2E consistently fail to delete workspaces.

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.

Deleted workspaces are still accessible via URL

4 participants