googleapis/mcp-toolbox · error

error : %v

Error message

error : %v

What it means

Thrown by checkError when the response from RunSQL (DQL query) or doLogin successfully unmarshals but contains a non-empty "errors" array — Dgraph rejected the request. The whole errors array is formatted into the message. This is Dgraph's standard GraphQL-style error envelope surfaced to the caller.

Source

Thrown at internal/sources/dgraph/dgraph.go:412

	}
	u.Path = resource
	u.RawQuery = params.Encode()
	return u.String(), nil
}

func checkError(resp []byte) error {
	var errResp struct {
		Errors []struct {
			Message string `json:"message"`
		} `json:"errors"`
	}

	if err := json.Unmarshal(resp, &errResp); err != nil {
		return fmt.Errorf("failed to unmarshal json: %v", err)
	}

	if len(errResp.Errors) > 0 {
		return fmt.Errorf("error : %v", errResp.Errors)
	}

	return nil
}

func embedParamsIntoMutation(mutation string, paramsMap map[string]interface{}) string {
	for key, value := range paramsMap {
		mutation = strings.ReplaceAll(mutation, key, fmt.Sprintf(`"%v"`, value))
	}
	return mutation
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Read the wrapped error messages to see Dgraph's own explanation (syntax, unknown field, permission denied).
  2. Test the DQL directly against Dgraph (curl -X POST /query or the Ratel UI) to reproduce and fix the query.
  3. Fix query syntax or add missing predicates to the Dgraph schema.
  4. For login failures, verify the username/password and that ACLs are correctly configured.

Example fix

// before (invalid DQL)
query := "{ q(func: eq(name, \"x\")" // missing closing brace
// after
query := "{ q(func: eq(name, \"x\")) }"
Defensive patterns

Strategy: try-catch

Validate before calling

// validate DQL syntax against Dgraph before shipping
curl -s -X POST http://dgraph:8080/query -H "Content-Type: application/dql" --data-binary '{ q(func: type(Entity)) { uid } }' | jq '.errors'

Try / catch

var dgraphErr struct{ Errors []struct{ Message string `json:"message"` } `json:"errors"` }
if err := json.Unmarshal(respBody, &dgraphErr); err == nil && len(dgraphErr.Errors) > 0 {
    for _, e := range dgraphErr.Errors {
        log.Printf("dgraph rejected the query: %s", e.Message)
    }
    // fix the DQL or permissions before retrying
}

Prevention

When it happens

Trigger: RunSQL posts a DQL query (or doLogin posts credentials) and the response JSON contains "errors": [{"message": ...}] with length > 0, e.g. syntax errors in the DQL, unknown predicates, or failed authentication.

Common situations: Malformed DQL syntax, querying predicates that don't exist in the schema, missing read/write ACL permissions, invalid username/password in doLogin, or an oversized/invalid mutation.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/26140f6505f8c3bc. Report an issue: GitHub.