{"record":{"id":"9096eac8dfa02f75","repo":"googleapis/mcp-toolbox","slug":"error-embedding-parameters-with-model-s-w","errorCode":null,"errorMessage":"error embedding parameters with model %s: %w","messagePattern":"error embedding parameters with model (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/parameters/parameters.go","lineNumber":220,"sourceCode":"\t\t})\n\t}\n\n\t// Batch embedding request sent to each model\n\tfor modelName, params := range parametersToEmbed {\n\t\tmodel, ok := pMgr.GetEmbeddingModel(modelName)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"embedding model does not exist: %s\", modelName)\n\t\t}\n\n\t\t// Extract only the string values for the API call\n\t\tstringBatch := make([]string, len(params))\n\t\tfor i, paramStr := range params {\n\t\t\tstringBatch[i] = paramStr.OriginalValue\n\t\t}\n\n\t\tembeddings, err := model.EmbedParameters(ctx, stringBatch)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error embedding parameters with model %s: %w\", modelName, err)\n\t\t}\n\n\t\tif len(embeddings) != len(stringBatch) {\n\t\t\treturn nil, fmt.Errorf(\"model %s returned %d embeddings for %d inputs\", modelName, len(embeddings), len(stringBatch))\n\t\t}\n\n\t\tfor i, rawVector := range embeddings {\n\n\t\t\titem := params[i]\n\n\t\t\t// Call vector formatter\n\t\t\tvar finalValue any = rawVector\n\n\t\t\tif formatter == nil {\n\t\t\t\tparamValues[item.Index].Value = finalValue\n\t\t\t\tcontinue\n\t\t\t}\n","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/util/parameters/parameters.go#L202-L238","documentation":"EmbedParams wraps any error returned by the embedding model's EmbedParameters API call with this message, preserving the root cause via %w. The model itself resolved fine, but the embedding request failed — the real cause (network, auth, provider error) is in the wrapped error after this prefix.","triggerScenarios":"model.EmbedParameters(ctx, stringBatch) returns a non-nil error during a batch embedding call: network failure to the provider, missing/invalid API credentials, quota or rate-limit rejection, or a provider 4xx/5xx response.","commonSituations":"Expired or absent provider API keys (env vars / ADC not set in the deployment environment); blocked egress in VPC or Cloud Run; hitting provider rate limits with large parameter batches; misconfigured model endpoint or project settings.","solutions":["Unwrap the error (errors.Unwrap / %w chain) and read the underlying provider message; fix that first.","Verify provider credentials (API key env vars, Application Default Credentials) are present and valid.","Test network connectivity to the embedding provider endpoint from the runtime environment.","Reduce batch size and add exponential backoff for rate-limit (429) responses; check quotas.","Confirm the model kind/name in config is one the provider actually supports."],"exampleFix":"// before: opaque wrapper only\nif err != nil { return err }\n\n// after: surface the root cause\nembeddings, err := model.EmbedParameters(ctx, batch)\nif err != nil {\n    return fmt.Errorf(\"embedding failed: %w\", err) // inspect wrapped cause\n}","handlingStrategy":"retry","validationCode":"// pre-flight at startup\nif _, err := model.EmbedParameters(ctx, []string{\"ping\"}); err != nil {\n    log.Fatalf(\"embedding provider unavailable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"embeddings, err := model.EmbedParameters(ctx, batch)\nif err != nil {\n    if isRetryable(err) { // 429/5xx\n        time.Sleep(backoff); return retry(batch)\n    }\n    return fmt.Errorf(\"embedding unavailable: %w\", err)\n}","preventionTips":["Provide provider credentials via env vars/secret manager and rotate them before expiry.","Pre-flight a tiny embedding call at startup to fail fast on auth or network issues.","Add retry with exponential backoff for rate limits; monitor quotas.","Verify egress/firewall rules allow the runtime to reach the provider endpoint."],"tags":["embeddings","network","api"],"backgroundTag":"embedding-request-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}