[PR #5962] fix: resolve invalid environment validation when publishing docs in personal workspace #5432

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

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5962
Author: @sahilkhan09k
Created: 3/7/2026
Status: 🔄 Open

Base: mainHead: fix-published-docs-environment-validation


📝 Commits (2)

  • 5c288bc fix: resolve invalid environment validation when publishing docs in personal workspace
  • eba920a Update packages/hoppscotch-backend/src/published-docs/published-docs.service.ts

📊 Changes

1 file changed (+39 additions, -18 deletions)

View changed files

📝 packages/hoppscotch-backend/src/published-docs/published-docs.service.ts (+39 -18)

📄 Description

Closes #5952

What's changed

Fixed an issue where publishing documentation in a personal workspace with an environment selected resulted in the error published_docs/invalid_environment.

Updated the fetchEnvironment method in published-docs.service.ts to fetch environments by ID first, and then validate workspace ownership in code.

This prevents false negatives caused by overly strict Prisma query filters while maintaining correct access validation.

Notes to reviewers

The previous implementation queried environments using both id and workspace ownership in the Prisma where clause. In some cases this returned null even when the environment existed.

The new implementation retrieves the environment by ID and then validates ownership (teamID or userUid) explicitly.

This keeps the authorization checks intact while resolving the error when publishing docs from personal workspaces.


Summary by cubic

Fixes published_docs/invalid_environment when publishing docs from personal workspaces by fetching environments by ID and validating ownership in code. Closes #5952.

  • Bug Fixes
    • Switched to findUnique(id) for teamEnvironment and userEnvironment.
    • Added explicit teamID/userUid ownership checks after fetch.
    • Removed nullable success path in fetchEnvironment; now returns Either with env data to avoid false negatives while keeping access control.

Written for commit eba920a8a1. Summary will update 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/5962 **Author:** [@sahilkhan09k](https://github.com/sahilkhan09k) **Created:** 3/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-published-docs-environment-validation` --- ### 📝 Commits (2) - [`5c288bc`](https://github.com/hoppscotch/hoppscotch/commit/5c288bc58d14823501bedcedc2d906c721c03ad2) fix: resolve invalid environment validation when publishing docs in personal workspace - [`eba920a`](https://github.com/hoppscotch/hoppscotch/commit/eba920a8a1caa88d3362148d227406582d1ea4f5) Update packages/hoppscotch-backend/src/published-docs/published-docs.service.ts ### 📊 Changes **1 file changed** (+39 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-backend/src/published-docs/published-docs.service.ts` (+39 -18) </details> ### 📄 Description Closes #5952 What's changed Fixed an issue where publishing documentation in a personal workspace with an environment selected resulted in the error published_docs/invalid_environment. Updated the fetchEnvironment method in published-docs.service.ts to fetch environments by ID first, and then validate workspace ownership in code. This prevents false negatives caused by overly strict Prisma query filters while maintaining correct access validation. Notes to reviewers The previous implementation queried environments using both id and workspace ownership in the Prisma where clause. In some cases this returned null even when the environment existed. The new implementation retrieves the environment by ID and then validates ownership (teamID or userUid) explicitly. This keeps the authorization checks intact while resolving the error when publishing docs from personal workspaces. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes published_docs/invalid_environment when publishing docs from personal workspaces by fetching environments by ID and validating ownership in code. Closes #5952. - **Bug Fixes** - Switched to `findUnique(id)` for `teamEnvironment` and `userEnvironment`. - Added explicit `teamID`/`userUid` ownership checks after fetch. - Removed nullable success path in `fetchEnvironment`; now returns Either with env data to avoid false negatives while keeping access control. <sup>Written for commit eba920a8a1caa88d3362148d227406582d1ea4f5. Summary will update 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>
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#5432
No description provided.