fix(project): restrict service columns in project.one for members - #5088
Open
Alexis0800 wants to merge 1 commit into
Open
fix(project): restrict service columns in project.one for members#5088Alexis0800 wants to merge 1 commit into
Alexis0800 wants to merge 1 commit into
Conversation
The member branch of project.one pulled the whole service tables inside a
`with`. Drizzle builds one json_build_array per nested relation with a single
argument per column, and Postgres allows at most 100 arguments per function
call. The application table crossed that limit at 101 columns, so the query
started failing with INTERNAL_SERVER_ERROR.
getServerSideProps catches that error and redirects away from the project, so
members with valid access saw the project card but never its services. Owners
and admins were unaffected because they go through findProjectById, which
already selects explicit columns.
This mirrors that same selection while keeping the accessedServices filters.
Reproduce the underlying limit on any Postgres instance:
SELECT json_build_array(1, 2, ..., 100); -- ok
SELECT json_build_array(1, 2, ..., 101); -- cannot pass more than 100
-- arguments to a function
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
What is this PR about?
Members with valid project access cannot open their projects: they see the project card, but clicking it redirects them away and they never reach their services. Owners and admins are unaffected.
The member branch of
project.onepulls the whole service tables inside awith. Drizzle builds onejson_build_arrayper nested relation with a single argument per column, and Postgres allows at most 100 arguments per function call. Theapplicationtable is now at 101 columns, so the query fails withINTERNAL_SERVER_ERROR.getServerSidePropscatches that error and redirects out of the project, which is why it looks like a permissions problem rather than a query failure.Owners and admins go through
findProjectById, which already selects explicit columns — that is why only members hit this.This PR mirrors that same column selection in the member branch while keeping the
accessedServicesfilters untouched. No behavioural change: members now receive exactly the same fields owners already receive.Reproducing the underlying limit
On any Postgres instance:
Quick one-liner:
psql -c "SELECT json_build_array($(seq -s, 1 101)) IS NOT NULL;"Note for maintainers
project.allandfindEnvironmentsByProjectIdalready restrict columns, so they are safe. This was the only remaining query selecting a full service table inside a nested relation. Since the limit is now only one column away from being crossed again by other tables, the added test asserts every service relation in the member branch keeps an explicitcolumns:selection.Checklist
Before submitting this PR, please make sure that:
canarybranch.Tested on a self-hosted instance running v0.30.0: before the change a member was redirected out of the project and the server logged the failing query; after the change the member opens the project and sees the services they were granted.
typecheckis clean and the permissions test suite passes (47 tests).Issues related (if applicable)
N/A
Greptile Summary
The PR prevents PostgreSQL’s function-argument limit from breaking
project.onefor members by explicitly selecting service columns while preserving existing access filters.Confidence Score: 5/5
The PR appears safe to merge, with no concrete changed-code regression identified.
The member query now limits every nested service relation while retaining the existing project organization scope and per-service access filters, and the selected response fields align with the established owner/admin query pattern.
Reviews (1): Last reviewed commit: "fix(project): restrict service columns i..." | Re-trigger Greptile