[PR #5624] [MERGED] hotfix: clean up published docs with deleted collections #5286

Closed
opened 2026-03-17 02:45:00 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5624
Author: @mirarifhasan
Created: 11/27/2025
Status: Merged
Merged: 12/2/2025
Merged by: @mirarifhasan

Base: patchHead: hotfix/api-doc-collection-deletetion


📝 Commits (3)

  • e14e028 feat: clean up published docs with deleted collections
  • 784a731 refactor: published docs creator session serialization
  • 0a70615 refactor: clean up orphaned published docs on fetch

📊 Changes

4 files changed (+279 additions, -15 deletions)

View changed files

📝 packages/hoppscotch-backend/src/published-docs/published-docs.resolver.ts (+2 -5)
📝 packages/hoppscotch-backend/src/published-docs/published-docs.service.spec.ts (+186 -3)
📝 packages/hoppscotch-backend/src/published-docs/published-docs.service.ts (+91 -6)
📝 packages/hoppscotch-backend/src/user-collection/user-collection.service.ts (+0 -1)

📄 Description

What's changed

This pull request enhances the handling of published documents in the backend by ensuring that only documents with existing collections are returned, and automatically cleaning up any published docs associated with deleted or missing collections. It also adds comprehensive tests to verify this new behavior for both user and team published documents.

Published Docs Consistency and Cleanup:

  • Updated getAllUserPublishedDocs and getAllTeamPublishedDocs methods in published-docs.service.ts to:
    • Cross-check that each published doc's collection exists before returning it.
    • Automatically delete any published docs referencing non-existent user or team collections.
    • Ensure only valid published docs (with existing collections) are returned to the caller. [1] [2]

Testing Enhancements:

  • Added and updated tests in published-docs.service.spec.ts to:
    • Verify that only published docs with existing collections are returned.
    • Confirm that published docs with missing collections are deleted.
    • Ensure no unnecessary deletions occur when all collections exist.
    • Thoroughly test these behaviors for both user and team published docs. [1] [2] [3] [4] [5] [6]

Minor Cleanup:

  • Removed an unused import from user-collection.service.ts.

Notes to reviewers

Nil


Summary by cubic

Ensure published docs only include entries whose collections still exist, and auto-delete orphaned records for users and teams. Also make the creator field nullable and move session serialization to the service.

  • Bug Fixes
    • Validate collection existence in getAllUserPublishedDocs and getAllTeamPublishedDocs.
    • Auto-delete orphaned docs on list and single fetch (getPublishedDocByID).
    • Return only valid docs; no deletions when all collections exist.
    • Make getPublishedDocsCreator return null when user is missing; mark resolver field nullable and handle session serialization in the service.
    • Added tests covering filtering, deletion, and pagination.
    • Removed an unused import.

Written for commit 0a70615eab. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5624 **Author:** [@mirarifhasan](https://github.com/mirarifhasan) **Created:** 11/27/2025 **Status:** ✅ Merged **Merged:** 12/2/2025 **Merged by:** [@mirarifhasan](https://github.com/mirarifhasan) **Base:** `patch` ← **Head:** `hotfix/api-doc-collection-deletetion` --- ### 📝 Commits (3) - [`e14e028`](https://github.com/hoppscotch/hoppscotch/commit/e14e028f7325f125007828c64ff61a576dee61dc) feat: clean up published docs with deleted collections - [`784a731`](https://github.com/hoppscotch/hoppscotch/commit/784a73107ddc1ba2cb18548675281fe5494c0ed3) refactor: published docs creator session serialization - [`0a70615`](https://github.com/hoppscotch/hoppscotch/commit/0a70615eab82ef724121c7620ec57f405fe65627) refactor: clean up orphaned published docs on fetch ### 📊 Changes **4 files changed** (+279 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-backend/src/published-docs/published-docs.resolver.ts` (+2 -5) 📝 `packages/hoppscotch-backend/src/published-docs/published-docs.service.spec.ts` (+186 -3) 📝 `packages/hoppscotch-backend/src/published-docs/published-docs.service.ts` (+91 -6) 📝 `packages/hoppscotch-backend/src/user-collection/user-collection.service.ts` (+0 -1) </details> ### 📄 Description <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> <!-- If this pull request closes an issue, please mention the issue number below --> <!-- Issue # here --> <!-- Add an introduction into what this PR tries to solve in a couple of sentences --> ### What's changed <!-- Describe point by point the different things you have changed in this PR --> This pull request enhances the handling of published documents in the backend by ensuring that only documents with existing collections are returned, and automatically cleaning up any published docs associated with deleted or missing collections. It also adds comprehensive tests to verify this new behavior for both user and team published documents. **Published Docs Consistency and Cleanup:** * Updated `getAllUserPublishedDocs` and `getAllTeamPublishedDocs` methods in `published-docs.service.ts` to: - Cross-check that each published doc's collection exists before returning it. - Automatically delete any published docs referencing non-existent user or team collections. - Ensure only valid published docs (with existing collections) are returned to the caller. [[1]](diffhunk://#diff-400fe090042ced037aa1709e4d74f1ea9c38a343b2dfb7e8b0969b204690fef5L269-R303) [[2]](diffhunk://#diff-400fe090042ced037aa1709e4d74f1ea9c38a343b2dfb7e8b0969b204690fef5L293-R361) **Testing Enhancements:** * Added and updated tests in `published-docs.service.spec.ts` to: - Verify that only published docs with existing collections are returned. - Confirm that published docs with missing collections are deleted. - Ensure no unnecessary deletions occur when all collections exist. - Thoroughly test these behaviors for both user and team published docs. [[1]](diffhunk://#diff-cfaca507098e0f26d160210a5cb4d5bd635ff3c47e1cf3ed0000ba8f3326c9d5R182-R184) [[2]](diffhunk://#diff-cfaca507098e0f26d160210a5cb4d5bd635ff3c47e1cf3ed0000ba8f3326c9d5R196) [[3]](diffhunk://#diff-cfaca507098e0f26d160210a5cb4d5bd635ff3c47e1cf3ed0000ba8f3326c9d5R208-R305) [[4]](diffhunk://#diff-cfaca507098e0f26d160210a5cb4d5bd635ff3c47e1cf3ed0000ba8f3326c9d5R318) [[5]](diffhunk://#diff-cfaca507098e0f26d160210a5cb4d5bd635ff3c47e1cf3ed0000ba8f3326c9d5R330-R332) [[6]](diffhunk://#diff-cfaca507098e0f26d160210a5cb4d5bd635ff3c47e1cf3ed0000ba8f3326c9d5R353-R434) **Minor Cleanup:** * Removed an unused import from `user-collection.service.ts`. <!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax - [ ] Not Completed - [x] Completed --> ### Notes to reviewers <!-- Any information you feel the reviewer should know about when reviewing your PR --> Nil <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Ensure published docs only include entries whose collections still exist, and auto-delete orphaned records for users and teams. Also make the creator field nullable and move session serialization to the service. - **Bug Fixes** - Validate collection existence in getAllUserPublishedDocs and getAllTeamPublishedDocs. - Auto-delete orphaned docs on list and single fetch (getPublishedDocByID). - Return only valid docs; no deletions when all collections exist. - Make getPublishedDocsCreator return null when user is missing; mark resolver field nullable and handle session serialization in the service. - Added tests covering filtering, deletion, and pagination. - Removed an unused import. <sup>Written for commit 0a70615eab82ef724121c7620ec57f405fe65627. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:45:00 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5286
No description provided.