Skip to content

feat: update DB endpoints to match current spec#635

Merged
paulo merged 1 commit intomasterfrom
pa/update-database-api-def
Apr 7, 2026
Merged

feat: update DB endpoints to match current spec#635
paulo merged 1 commit intomasterfrom
pa/update-database-api-def

Conversation

@paulo
Copy link
Copy Markdown
Contributor

@paulo paulo commented Apr 7, 2026

implementation has drifted a bit, just putting it back on track

@paulo paulo requested review from eduardoboucas and kathmbeck April 7, 2026 07:56
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 7, 2026

Deploy Preview for open-api ready!

Name Link
🔨 Latest commit 96aa64a
🔍 Latest deploy log https://app.netlify.com/projects/open-api/deploys/69d4b8b02ab6d90008d1502c
😎 Deploy Preview https://deploy-preview-635--open-api.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added database branch compute settings management at both branch and project levels
    • Added ability to list database branches with detailed status information
    • Added database migration execution capability
    • Added role-based selection for database connection strings
    • Enhanced database snapshots with additional metadata (source, creation time, expiration time)
    • Added metadata support to database branches and snapshots

Walkthrough

This pull request refactors database branch management from a deploy-scoped to a branch-scoped model by systematically replacing deploy_id identifiers with branch_id across API operations, request/response models, and client plumbing. It introduces compute settings management at both branch and project levels via new endpoints, adds support for database role selection when retrieving connection strings, creates new response models for branch details and compute information, and implements database migration execution. The swagger API definition is updated with new paths, parameters, and schemas to reflect these structural changes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main purpose of the changeset: updating database endpoints to align with the current API specification.
Description check ✅ Passed The description is relevant to the changeset, explaining that the implementation had drifted and is being realigned with the specification.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pa/update-database-api-def

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@paulo paulo marked this pull request as ready for review April 7, 2026 08:04
@paulo paulo requested review from a team as code owners April 7, 2026 08:04
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
go/models/database_compute_settings.go (1)

18-30: Consider adding contract-level bounds for compute settings.

Validate is currently a no-op, so negative/invalid numeric combinations won’t be caught client-side. If these fields have domain constraints, encode them in the OpenAPI schema so generated validation enforces them automatically.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go/models/database_compute_settings.go` around lines 18 - 30, The Validate
method on DatabaseComputeSettings is a no-op so invalid values slip through;
update DatabaseComputeSettings.Validate to check that MaxCu and MinCu are
non-negative, that MinCu <= MaxCu when both are set, and that
SleepTimeoutSeconds is non-negative (and enforce any additional domain rules you
expect), returning a descriptive error on violation; also add corresponding
constraints to the OpenAPI/schema for MaxCu, MinCu, and SleepTimeoutSeconds so
generated validation will catch these rules in clients and server stubs.
go/plumbing/operations/delete_site_database_branch_parameters.go (1)

110-119: Add explicit SDK migration notes for renamed fluent methods.

Removing WithDeployID/SetDeployID is a source-level client break; please call this out in changelog/release notes with a concise before/after example.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go/plumbing/operations/delete_site_database_branch_parameters.go` around
lines 110 - 119, The public API removed WithDeployID/SetDeployID and introduced
WithBranchID/SetBranchID (methods on DeleteSiteDatabaseBranchParams), which is a
source-breaking change; update the release notes/changelog to include an
explicit SDK migration note that documents the rename with a concise
before/after example showing callers replacing WithDeployID(...) /
SetDeployID(...) with WithBranchID(...) / SetBranchID(...), and mention the
impacted type DeleteSiteDatabaseBranchParams so users can find and update
usages.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@go/plumbing/operations/operations_client.go`:
- Line 42: The added method ClearSiteDatabaseComputeSettings on the exported
ClientService interface is a source-breaking change for downstream
implementations; update consumer-facing artifacts by (a) documenting this as a
breaking change in the release notes/CHANGELOG referencing ClientService and the
new ClearSiteDatabaseComputeSettings method, and (b) bumping the module major
version (or otherwise following your semver policy) so downstream users know to
update their implementations; alternatively consider providing a compatibility
shim or helper stub for ClientService to ease migration for existing custom
implementations.

In
`@go/plumbing/operations/set_site_database_branch_compute_settings_parameters.go`:
- Around line 160-163: The generated client currently doesn't enforce the CU
bounds/cross-field invariants because DatabaseComputeSettingsRequest.Validate()
is a no-op; update the API/swagger schema for DatabaseComputeSettingsRequest to
encode the documented constraints (min/max for CU fields and any cross-field
rules such as lower <= upper or mutual exclusivity) so the code generator will
emit proper validation, then re-generate the client so calls that set
o.ComputeSettings (used in SetBodyParam) will be validated locally via the
generated Validate() method before being sent.

In `@go/plumbing/operations/set_site_database_compute_settings_parameters.go`:
- Around line 139-143: In WriteToRequest for the
SetSiteDatabaseComputeSettingsParameters operation (the code block that
currently checks o.ComputeSettings and calls r.SetBodyParam), add a guard that
returns an error when o.ComputeSettings is nil so the client fails fast for
bodyless project-level compute updates; update the function (WriteToRequest) on
the SetSiteDatabaseComputeSettingsParameters type to validate ComputeSettings is
present before calling r.SetBodyParam and return a descriptive error (e.g.,
"ComputeSettings is required") instead of silently sending an empty PUT.

In `@swagger.yml`:
- Around line 3902-3927: The schema for databaseComputeSettingsRequest currently
uses non-nullable numeric types so the generated Go client cannot distinguish
"unset" from zero and the generated Validate() is a no-op; update the OpenAPI
schema to mark min_cu, max_cu, and sleep_timeout_seconds as nullable (e.g., add
nullable: true) and add proper numeric constraints (min_cu and max_cu: minimum
0.25, maximum 16.0; also document/express that max_cu - min_cu must be <= 8.0;
sleep_timeout_seconds: allow -1 or any non-negative integer) so the generator
produces pointer types, and then implement validation logic in the model's
Validate() method (DatabaseComputeSettingsRequest.Validate) to: treat nil
pointers as "not provided", enforce min/max bounds on provided values, ensure
max_cu >= min_cu when both provided, and ensure (max_cu - min_cu) <= 8.0; keep
error messages clear and reference the field names min_cu, max_cu,
sleep_timeout_seconds.

---

Nitpick comments:
In `@go/models/database_compute_settings.go`:
- Around line 18-30: The Validate method on DatabaseComputeSettings is a no-op
so invalid values slip through; update DatabaseComputeSettings.Validate to check
that MaxCu and MinCu are non-negative, that MinCu <= MaxCu when both are set,
and that SleepTimeoutSeconds is non-negative (and enforce any additional domain
rules you expect), returning a descriptive error on violation; also add
corresponding constraints to the OpenAPI/schema for MaxCu, MinCu, and
SleepTimeoutSeconds so generated validation will catch these rules in clients
and server stubs.

In `@go/plumbing/operations/delete_site_database_branch_parameters.go`:
- Around line 110-119: The public API removed WithDeployID/SetDeployID and
introduced WithBranchID/SetBranchID (methods on DeleteSiteDatabaseBranchParams),
which is a source-breaking change; update the release notes/changelog to include
an explicit SDK migration note that documents the rename with a concise
before/after example showing callers replacing WithDeployID(...) /
SetDeployID(...) with WithBranchID(...) / SetBranchID(...), and mention the
impacted type DeleteSiteDatabaseBranchParams so users can find and update
usages.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 38c5beb6-3d83-49b5-ba31-2d48ac0ae969

📥 Commits

Reviewing files that changed from the base of the PR and between dafd938 and 96aa64a.

📒 Files selected for processing (32)
  • go/models/create_database_branch_request.go
  • go/models/create_database_snapshot_request.go
  • go/models/database_branch_compute.go
  • go/models/database_branch_detail.go
  • go/models/database_branch_response.go
  • go/models/database_branches_response.go
  • go/models/database_compute_settings.go
  • go/models/database_compute_settings_request.go
  • go/models/database_snapshot.go
  • go/models/database_snapshot_metadata.go
  • go/models/restore_database_snapshot_request.go
  • go/models/run_database_migrations_request.go
  • go/plumbing/operations/clear_site_database_compute_settings_parameters.go
  • go/plumbing/operations/clear_site_database_compute_settings_responses.go
  • go/plumbing/operations/create_site_database_branch_responses.go
  • go/plumbing/operations/delete_site_database_branch_parameters.go
  • go/plumbing/operations/delete_site_database_branch_responses.go
  • go/plumbing/operations/get_site_database_branch_parameters.go
  • go/plumbing/operations/get_site_database_branch_responses.go
  • go/plumbing/operations/get_site_database_compute_settings_parameters.go
  • go/plumbing/operations/get_site_database_compute_settings_responses.go
  • go/plumbing/operations/get_site_database_parameters.go
  • go/plumbing/operations/list_site_database_branches_parameters.go
  • go/plumbing/operations/list_site_database_branches_responses.go
  • go/plumbing/operations/operations_client.go
  • go/plumbing/operations/run_site_database_migrations_parameters.go
  • go/plumbing/operations/run_site_database_migrations_responses.go
  • go/plumbing/operations/set_site_database_branch_compute_settings_parameters.go
  • go/plumbing/operations/set_site_database_branch_compute_settings_responses.go
  • go/plumbing/operations/set_site_database_compute_settings_parameters.go
  • go/plumbing/operations/set_site_database_compute_settings_responses.go
  • swagger.yml


CancelSiteDeploy(params *CancelSiteDeployParams, authInfo runtime.ClientAuthInfoWriter) (*CancelSiteDeployCreated, error)

ClearSiteDatabaseComputeSettings(params *ClearSiteDatabaseComputeSettingsParams, authInfo runtime.ClientAuthInfoWriter) (*ClearSiteDatabaseComputeSettingsNoContent, error)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In Go, is adding a method to an exported interface a source-breaking change for existing downstream implementations?

💡 Result:

Yes. In Go, a concrete type satisfies an interface only if it implements all of the interface’s methods, so adding a new method to an exported interface makes any existing downstream type that implemented the old interface stop compiling (“does not implement … (missing method …)”). This is a source-breaking API change for any users who provide their own implementations/mocks of that interface. [1], [2]

A common mitigation is to design so users don’t implement your exported interface (e.g., return concrete types and let consumers define their own interfaces), or to “seal” the interface by including an unexported method so only your package can implement it—then you can add exported methods later without breaking external implementations (because there are none). [1], [3]

Sources:
[1] Go blog: Keeping Your Modules Compatible
[2] Merovius: Backwards compatibility in Go
[3] apidiff compatibility rules (Go exp tool)


🏁 Script executed:

# Check the file structure and find the ClientService interface definition
cd go/plumbing/operations && head -100 operations_client.go | cat -n

Repository: netlify/open-api

Length of output: 6134


🏁 Script executed:

# Search for the ClientService interface definition
rg "type ClientService" go/plumbing/operations/ -A 20

Repository: netlify/open-api

Length of output: 2333


🏁 Script executed:

# Check the specific lines mentioned in the review (42, 210, 262, 304-312)
sed -n '40,45p;208,212p;260,265p;302,315p' go/plumbing/operations/operations_client.go | cat -n

Repository: netlify/open-api

Length of output: 2476


🏁 Script executed:

# Check if there's an unexported method or sealing pattern in the interface
rg "type ClientService" go/plumbing/operations/operations_client.go -A 300 | head -350 | tail -20

Repository: netlify/open-api

Length of output: 1338


🏁 Script executed:

# Check for any version information or generator configuration
fd "swagger\|openapi\|generator" go/plumbing/ 2>/dev/null | head -10

Repository: netlify/open-api

Length of output: 42


Note that ClientService interface expansion is a source-breaking change for downstream implementations.

In Go, adding methods to an exported interface requires all existing implementations to add those methods, breaking any downstream custom implementations or mocks. However, since operations_client.go is auto-generated from the OpenAPI spec by go-swagger, this is an inevitable consequence of API evolution. Consider communicating this as a breaking change in release notes or bump the module version accordingly if backward compatibility matters for your consumers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go/plumbing/operations/operations_client.go` at line 42, The added method
ClearSiteDatabaseComputeSettings on the exported ClientService interface is a
source-breaking change for downstream implementations; update consumer-facing
artifacts by (a) documenting this as a breaking change in the release
notes/CHANGELOG referencing ClientService and the new
ClearSiteDatabaseComputeSettings method, and (b) bumping the module major
version (or otherwise following your semver policy) so downstream users know to
update their implementations; alternatively consider providing a compatibility
shim or helper stub for ClientService to ease migration for existing custom
implementations.

Comment on lines +160 to +163
if o.ComputeSettings != nil {
if err := r.SetBodyParam(o.ComputeSettings); err != nil {
return err
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Encode the CU invariants in the schema before regenerating.

DatabaseComputeSettingsRequest documents bounds and cross-field rules, but its generated Validate() is currently a no-op, so this writer won't reject out-of-range or inverted values locally. If those constraints are part of the contract, add them to the swagger schema so the generated client enforces them too.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@go/plumbing/operations/set_site_database_branch_compute_settings_parameters.go`
around lines 160 - 163, The generated client currently doesn't enforce the CU
bounds/cross-field invariants because DatabaseComputeSettingsRequest.Validate()
is a no-op; update the API/swagger schema for DatabaseComputeSettingsRequest to
encode the documented constraints (min/max for CU fields and any cross-field
rules such as lower <= upper or mutual exclusivity) so the code generator will
emit proper validation, then re-generate the client so calls that set
o.ComputeSettings (used in SetBodyParam) will be validated locally via the
generated Validate() method before being sent.

Comment on lines +139 to +143
if o.ComputeSettings != nil {
if err := r.SetBodyParam(o.ComputeSettings); err != nil {
return err
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Reject bodyless project-level compute updates locally.

WriteToRequest will happily send PUT /sites/{site_id}/database/compute/settings with no payload when ComputeSettings is nil. Since reset already has a dedicated DELETE, this should be modeled as a required body in the swagger spec so the generated client fails fast instead of round-tripping a 4xx.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go/plumbing/operations/set_site_database_compute_settings_parameters.go`
around lines 139 - 143, In WriteToRequest for the
SetSiteDatabaseComputeSettingsParameters operation (the code block that
currently checks o.ComputeSettings and calls r.SetBodyParam), add a guard that
returns an error when o.ComputeSettings is nil so the client fails fast for
bodyless project-level compute updates; update the function (WriteToRequest) on
the SetSiteDatabaseComputeSettingsParameters type to validate ComputeSettings is
present before calling r.SetBodyParam and return a descriptive error (e.g.,
"ComputeSettings is required") instead of silently sending an empty PUT.

Comment on lines +3902 to +3927
databaseComputeSettingsRequest:
type: object
description: >-
Request body for setting compute settings.
All fields are optional; only provided fields are updated.
properties:
min_cu:
type: number
format: double
description: >-
Minimum compute units (0.25 to 16.0).
Must be less than or equal to max_cu.
max_cu:
type: number
format: double
description: >-
Maximum compute units (0.25 to 16.0).
Must be greater than or equal to min_cu.
max_cu - min_cu must not exceed 8.0.
sleep_timeout_seconds:
type: integer
format: int64
description: >-
Seconds of inactivity before the compute endpoint is suspended.
Use -1 for always on, or a non-negative value.
databaseComputeSettings:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Swagger fragment:"
sed -n '3902,3927p' swagger.yml
echo
echo "Generated Go model:"
sed -n '13,35p' go/models/database_compute_settings_request.go

Repository: netlify/open-api

Length of output: 1954


Make the compute-settings patch fields nullable and machine-validated.

These properties are documented as optional partial-update fields, but the schema defines them as plain numbers/integers without nullable or validation constraints. The generated Go client uses value types (float64 for min_cu/max_cu, int64 for sleep_timeout_seconds) with omitempty tags, which cannot distinguish between "not provided" and "provided as zero". Additionally, the Validate() method is a no-op that performs no range checking, allowing out-of-range values to be sent.

Recommended schema adjustments
   databaseComputeSettingsRequest:
     type: object
     description: >-
       Request body for setting compute settings.
       All fields are optional; only provided fields are updated.
     properties:
       min_cu:
         type: number
         format: double
+        x-nullable: true
+        minimum: 0.25
+        maximum: 16.0
         description: >-
           Minimum compute units (0.25 to 16.0).
           Must be less than or equal to max_cu.
       max_cu:
         type: number
         format: double
+        x-nullable: true
+        minimum: 0.25
+        maximum: 16.0
         description: >-
           Maximum compute units (0.25 to 16.0).
           Must be greater than or equal to min_cu.
           max_cu - min_cu must not exceed 8.0.
       sleep_timeout_seconds:
         type: integer
         format: int64
+        x-nullable: true
+        minimum: -1
         description: >-
           Seconds of inactivity before the compute endpoint is suspended.
           Use -1 for always on, or a non-negative value.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
databaseComputeSettingsRequest:
type: object
description: >-
Request body for setting compute settings.
All fields are optional; only provided fields are updated.
properties:
min_cu:
type: number
format: double
description: >-
Minimum compute units (0.25 to 16.0).
Must be less than or equal to max_cu.
max_cu:
type: number
format: double
description: >-
Maximum compute units (0.25 to 16.0).
Must be greater than or equal to min_cu.
max_cu - min_cu must not exceed 8.0.
sleep_timeout_seconds:
type: integer
format: int64
description: >-
Seconds of inactivity before the compute endpoint is suspended.
Use -1 for always on, or a non-negative value.
databaseComputeSettings:
databaseComputeSettingsRequest:
type: object
description: >-
Request body for setting compute settings.
All fields are optional; only provided fields are updated.
properties:
min_cu:
type: number
format: double
x-nullable: true
minimum: 0.25
maximum: 16.0
description: >-
Minimum compute units (0.25 to 16.0).
Must be less than or equal to max_cu.
max_cu:
type: number
format: double
x-nullable: true
minimum: 0.25
maximum: 16.0
description: >-
Maximum compute units (0.25 to 16.0).
Must be greater than or equal to min_cu.
max_cu - min_cu must not exceed 8.0.
sleep_timeout_seconds:
type: integer
format: int64
x-nullable: true
minimum: -1
description: >-
Seconds of inactivity before the compute endpoint is suspended.
Use -1 for always on, or a non-negative value.
databaseComputeSettings:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@swagger.yml` around lines 3902 - 3927, The schema for
databaseComputeSettingsRequest currently uses non-nullable numeric types so the
generated Go client cannot distinguish "unset" from zero and the generated
Validate() is a no-op; update the OpenAPI schema to mark min_cu, max_cu, and
sleep_timeout_seconds as nullable (e.g., add nullable: true) and add proper
numeric constraints (min_cu and max_cu: minimum 0.25, maximum 16.0; also
document/express that max_cu - min_cu must be <= 8.0; sleep_timeout_seconds:
allow -1 or any non-negative integer) so the generator produces pointer types,
and then implement validation logic in the model's Validate() method
(DatabaseComputeSettingsRequest.Validate) to: treat nil pointers as "not
provided", enforce min/max bounds on provided values, ensure max_cu >= min_cu
when both provided, and ensure (max_cu - min_cu) <= 8.0; keep error messages
clear and reference the field names min_cu, max_cu, sleep_timeout_seconds.

@paulo paulo merged commit b9d885b into master Apr 7, 2026
15 checks passed
@paulo paulo deleted the pa/update-database-api-def branch April 7, 2026 08:52
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.

2 participants