fix(source/cloud-sql-admin): validate source instance for backup-run restore#3555
Open
anxkhn wants to merge 1 commit into
Open
fix(source/cloud-sql-admin): validate source instance for backup-run restore#3555anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Contributor
There was a problem hiding this comment.
Code Review
This pull request corrects a validation check in the Cloud SQL Admin source's RestoreBackup function, ensuring that sourceInstance is verified instead of targetInstance when restoring via a backup ID. A new integration test case has been added to cover this scenario. I have no feedback to provide as there are no review comments.
anxkhn
force-pushed
the
loop/mcp-toolbox__003
branch
from
July 1, 2026 07:40
74d8b34 to
56ec7a9
Compare
…restore
RestoreBackup's BackupRun-ID path consumes sourceProject + sourceInstance, but the guard required sourceProject + targetInstance. targetInstance is already mandatory for the RestoreBackup API call, so an empty source_instance slipped through and a malformed RestoreBackupContext{InstanceId:""} was sent. Validate sourceInstance, matching the tool parameter and docs that mark both source fields required when backup_id is a BackupRun ID. Adds a regression test case.
anxkhn
force-pushed
the
loop/mcp-toolbox__003
branch
from
July 1, 2026 18:01
56ec7a9 to
8be4de2
Compare
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.
Description
Source.RestoreBackupininternal/sources/cloudsqladmin/cloud_sql_admin.govalidates the wrong field on the BackupRun-ID restore path. Whenbackup_idis a numeric BackupRun ID, the code populatesRestoreBackupContextfromsourceProjectandsourceInstance, but the guard checkssourceProjectandtargetInstance:targetInstanceis already mandatory for the API call itself (service.Instances.RestoreBackup(targetProject, targetInstance, request)), so the guard never adds anything for it. The only thing it lets through is an emptysource_instance, which then sends a malformedRestoreBackupContext{InstanceId: ""}to the API.The error message already reads "source project and instance are required", and both the tool parameter description (
internal/tools/cloudsql/cloudsqlrestorebackup/cloudsqlrestorebackup.go) and the docs (docs/en/integrations/cloud-sql-admin/tools/cloudsqlrestorebackup.md) state that bothsource_projectandsource_instanceare required whenbackup_idis a BackupRun ID. So this is a one-character copy/paste bug, not intended behavior.Fix: guard on
sourceInstance == ""instead oftargetInstance == "". The error string is unchanged. A regression row is added to the existingtests/cloudsql/cloud_sql_restore_backup_test.gotable for the case wheresource_projectis set butsource_instanceis omitted, which fails before the fix (an emptyInstanceIdreaches the API) and passes after.PR Checklist
CONTRIBUTING.md
bug/issue
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
!if this involve a breaking change