bytebase/bytebase · error
database is required
Error message
database is required
What it means
The MCP change tool (handleChange) validates its input in step 1: database, sql, and title are all mandatory. An empty input.Database cannot identify the target database for the schema-change pipeline, so it throws this error first.
Source
Thrown at backend/api/mcp/tool_change.go:167
**Notes:**
- v1 supports single database targets only. For batch changes across multiple databases, use get_skill("database-change").
- Plan checks run automatically; results included in response when available.
- Requires bb.sheets.create, bb.plans.create, bb.issues.create permissions.
- If createRollout=true but policy gates aren't satisfied, returns success with rolloutCreated=false and a reason.
- Masked data: a masked column reads back as "******". That is a placeholder, not a value anything holds. Any change containing it is refused, because writing it back would overwrite the real value. Ask a human to make the change in the Bytebase console instead.
`
func (s *Server) registerChangeTool() {
mcp.AddTool(s.mcpServer, &mcp.Tool{
Name: "propose_database_change",
Description: proposeChangeDescription,
}, s.handleChange)
}
func (s *Server) handleChange(ctx context.Context, req *mcp.CallToolRequest, input ChangeInput) (*mcp.CallToolResult, any, error) {
// Step 1: Validate input.
if input.Database == "" {
return nil, nil, errors.New("database is required")
}
if input.SQL == "" {
return nil, nil, errors.New("sql is required")
}
if input.Title == "" {
return nil, nil, errors.New("title is required")
}
changeType := input.ChangeType
if changeType == "" {
changeType = changeTypeMigrate
}
if changeType != changeTypeMigrate && changeType != changeTypeSDL {
return formatToolError(&toolError{
Code: "INVALID_ARGUMENT",
Message: fmt.Sprintf("invalid changeType %q", changeType),
Suggestion: "allowed values: MIGRATE, SDL",
}), nil, nilView on GitHub (pinned to 1870550677)
Solutions
- Provide the database resource name (e.g. instances/{instance}/databases/{db}) in the change tool input.
- List available databases first (search/list tool) and pick a valid database name before calling change.
- Verify the MCP client serializes the database field with the exact expected key.
- Client-side: validate required fields (database, sql, title) before dispatching the tool call.
Example fix
// before
await callTool('change', { sql: 'CREATE TABLE t(id INT)', title: 'add t' });
// after
await callTool('change', { database: 'instances/prod/databases/appdb', sql: 'CREATE TABLE t(id INT)', title: 'add t' }); Defensive patterns
Strategy: validation
Validate before calling
for (const field of ['database', 'sql', 'title'] as const) {
if (!input[field]) throw new Error(`${field} is required`);
} Type guard
function isCompleteChangeInput(i: ChangeInput): boolean {
return i.database !== '' && i.sql !== '' && i.title !== '';
} Try / catch
try {
return await callTool('change', input);
} catch (e) {
if (String(e).includes('database is required')) {
const dbs = await callTool('search_database', {});
return await callTool('change', { ...input, database: dbs[0].name });
}
throw e;
} Prevention
- Resolve and set the target database name before composing the change request
- List databases via the discovery tool when the target is ambiguous
- Validate all required fields (database, sql, title) in the client wrapper before dispatch
When it happens
Trigger: Invoking the change tool with input.database empty — omitted field in the tool call, an LLM agent that filled only sql/title, or a client binding that maps the database argument to the wrong key.
Common situations: AI agent constructs a change request without resolving which database to target; manual tool invocation in tests missing the database argument; renamed/renumbered input fields breaking argument deserialization so Database defaults to "".
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06).
Data as JSON: /api/errors/65efd0e4a505d259.
Report an issue: GitHub.