Skip to content

Feature: Dashboard DB access routes#2153

Merged
ben-fornefeld merged 29 commits into
mainfrom
feature/dashboard-supabase-admin-migration
Mar 21, 2026
Merged

Feature: Dashboard DB access routes#2153
ben-fornefeld merged 29 commits into
mainfrom
feature/dashboard-supabase-admin-migration

Conversation

@ben-fornefeld
Copy link
Copy Markdown
Member

@ben-fornefeld ben-fornefeld commented Mar 18, 2026

Note

Medium Risk
Adds new dashboard API endpoints plus DB schema/query changes (team profile picture, default templates, team membership mutations) that impact persisted data and authorization checks. Main risk is incorrect auth/team scoping or transactional edge cases when adding/removing members.

Overview
Adds Dashboard API endpoints to list a user’s teams, resolve a team by slug, update team details (including clearing profilePictureUrl), manage team members (list/add/remove with transactional locking to prevent removing defaults/last member), and list default templates with latest uploaded build info and aliases. This is backed by new dashboard DB migrations (env_defaults, teams.profile_picture_url), new sqlc queries/types for teams/members/templates, and a shared ginutils body parsing helper that replaces the API service’s local request parsing utility.

Written by Cursor Bugbot for commit 3bd7da4. This will update automatically on new commits. Configure here.

Comment thread packages/dashboard-api/internal/handlers/team_members.go
Comment thread packages/dashboard-api/internal/handlers/team_members.go Outdated
@ben-fornefeld ben-fornefeld marked this pull request as ready for review March 19, 2026 18:50
Comment thread packages/db/pkg/dashboard/sql_queries/teams/update_team.sql Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3241207317

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@@ -0,0 +1,21 @@
-- +goose Up
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move migration into the directory the migrator actually runs

This migration is added under packages/db/pkg/dashboard/migrations, but our migration runner and version gating only read packages/db/migrations (see packages/db/scripts/migrator.go using migrationsDir = "./migrations" and scripts/get-latest-migration.sh scanning packages/db/migrations). That means public.env_defaults and teams.profile_picture_url will not be created in deployed databases while new queries already reference them, causing runtime SQL errors on the new dashboard endpoints.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

expected for now.

Comment thread packages/dashboard-api/internal/handlers/team_update.go Outdated
"github.com/e2b-dev/infra/packages/shared/pkg/telemetry"
)

func (s *APIStore) PatchTeamsTeamId(c *gin.Context, _ api.TeamId) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate the teamId path parameter before updating

This endpoint ignores the teamId path parameter (_ api.TeamId) and updates teamInfo.Team.ID from auth context instead, so /teams/{A} with header team {B} still mutates team B. That mismatch makes the URL identity unreliable and can lead clients to update the wrong team unless path and auth team are explicitly checked.

Useful? React with 👍 / 👎.

Comment thread packages/db/queries/teams/team_members.sql Outdated
Copy link
Copy Markdown
Contributor

@dobrac dobrac left a comment

Choose a reason for hiding this comment

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

lgtm in general, just small nits

Comment thread packages/dashboard-api/internal/handlers/teams_resolve.go Outdated
Comment thread packages/dashboard-api/internal/handlers/team_update.go
Comment thread packages/dashboard-api/internal/handlers/team_members.go Outdated
@dobrac dobrac assigned dobrac and unassigned ValentaTomas Mar 19, 2026
Comment thread packages/dashboard-api/internal/handlers/team_members.go
Comment thread packages/dashboard-api/internal/handlers/team_members.go
Comment thread packages/dashboard-api/internal/handlers/team_members.go
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread packages/dashboard-api/internal/handlers/team_members.go Outdated
Copy link
Copy Markdown
Contributor

@dobrac dobrac left a comment

Choose a reason for hiding this comment

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

please check the open conversations, otherwise lgtm!

return &b.Name
}

func parseUpdateTeamBody(bodyReader io.Reader) (updateTeamBody, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this function is now not used, correct?

Copy link
Copy Markdown
Member Author

@ben-fornefeld ben-fornefeld Mar 20, 2026

Choose a reason for hiding this comment

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

no it's still used. the abstraction i added takes custom io.Reader parser as input

@ValentaTomas ValentaTomas removed their request for review March 21, 2026 06:39
@ben-fornefeld ben-fornefeld merged commit e17006c into main Mar 21, 2026
36 checks passed
@ben-fornefeld ben-fornefeld deleted the feature/dashboard-supabase-admin-migration branch March 21, 2026 06:44
ValentaTomas pushed a commit that referenced this pull request May 4, 2026
* wip: create initial routes and queries

* add: resolve team by slug

* revert: outcommented sql migration check in dashboard api

* chore: auto-commit generated changes

* fix: update description for team identity resolution endpoint to clarify slug usage

* feat: profile picture crud

* chore: auto-commit generated changes

* chore: move sql and migration files from this branch into separate dashboard db pkg

* refactor: update database access method in teams_list handler and regenerate protobuf files with protoc-gen-go v1.36.11

* chore: auto-commit generated changes

* refactor: rename GetDefaultTemplateAliases method and remove unused SQL queries related to team members and team resolution

* chore: address comments

* improve: team member update error handling + update team profile picture clearability

* chore: auto-commit generated changes

* refactor: standardize team ID naming across API and handlers

* fix: lint

* chore: share gin body parser utils

* refactor: update team member handling and improve error management in API

* test: add unit test for handling deletion of default team members and ensure proper locking behavior

* chore: auto-commit generated changes

* refactor: team member add/delete handling

* add: team blockage information in teams list

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants