Installation

Install as Agent Plugin Recommended
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install application-integration-troubleshooting@skills-hub

Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled). Plugin application-integration-troubleshooting v1.0.0 follows the Agent Plugins spec.

Install with the gh extension
gh skills-hub install application-integration-troubleshooting

Don't have the extension? Run gh extension install samueltauil/skills-hub first.

Download and extract to your repository:

.github/skills/application-integration-troubleshooting/

Extract the ZIP to .github/skills/ in your repo. The folder name must match application-integration-troubleshooting for Copilot to auto-discover it.

Skill Files (7)

SKILL.md 23.6 KB
---
name: application-integration-troubleshooting
metadata:
  version: "1.0.2"
  category: ApplicationDevelopment
description: >-
  Diagnoses failed, stuck, or silent Google Cloud Application Integration runs and
  Integration Connectors tasks using the REST API, Cloud Logging, and Cloud Monitoring.
  Use when an integration fails, returns HTTP 200 without doing the expected work, hangs
  in a suspended or retry state, or hits IAM, run-as service account, connector health,
  or quota errors. Do not use for initial region provisioning (use
  application-integration-basics) or building and deploying versions (use application-integration-authoring).
---

# Application Integration Troubleshooting

Diagnose and recover Google Cloud Application Integration executions that fail, stall, or appear to do nothing. This skill walks through execution state verification, per-task failure inspection, Cloud Logging and Cloud Monitoring checks, Integration Connectors health probes, suspension resolution, and IAM or quota checks.

## Attribution

**MUST READ**: Before executing any `gcloud` command, REST API call, or Python
discovery-client call, you MUST read
[Usage Attribution](references/attribution.md). For commands executed directly
in the terminal (never in generated scripts, Terraform, ADK agents, or user
code), prefix `gcloud` with
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:application-integration-troubleshooting)"`
and add `agent-skills/1.0 (skill:application-integration-troubleshooting)` to
the `User-Agent` header of `curl` requests.

## Tooling and Scope Boundaries

- **REST is the interface.** There is no `gcloud integrations` command group and no Google-managed MCP server for Application Integration. Use `curl` with `gcloud auth print-access-token`, or the discovery-based Python client (`googleapiclient.discovery.build("integrations", "v1")` and `build("connectors", "v1")`; install with `pip install "google-api-python-client>=2.100.0,<3" "google-auth>=2.20.0,<3"`) (changes host or credential state; get the user's approval first).
- **Generic `gcloud` commands apply** for authentication (`gcloud auth`), enabling APIs (`gcloud services`), IAM checks (`gcloud projects get-iam-policy`, `gcloud iam service-accounts get-iam-policy`), and log queries (`gcloud logging read`).
- **Regional scope.** Integrations, executions, connections, and execution logs live in a single Google Cloud region (`LOCATION`), which is the `LOCATION` in every REST path; no `gcloud` default-region setting applies. Ask the user which region the integration is deployed in. If they don't know, start with `us-central1` and, if `executions.list` is empty there, check the other [Application Integration locations](https://docs.cloud.google.com/application-integration/docs/locations.md.txt) before concluding nothing ran (Step 2).
- **Sibling skills:**
  - Use `application-integration-basics` for product concepts, enabling APIs, provisioning a region, initial IAM roles, and service limits.
  - Use `application-integration-authoring` for creating drafts, editing tasks and triggers, config variables, publishing, `:execute` and `:schedule` payloads, and CI/CD export/import.

## Safety and Confirmation Rules

- **Read-only checks run freely:** `executions.list`, `suspensions.list`, `connections.get`, `connectionSchemaMetadata` get calls, runtime v2 `actions.list` / `entityTypes.list`, `gcloud logging read`, and `v2` `executions:troubleshoot`.
- **State-changing actions require explicit user confirmation.** Before canceling or replaying an execution, lifting or resolving a suspension, refreshing connector schema metadata, repairing connector eventing, publishing or unpublishing a version, or changing IAM bindings, show the exact command and wait for user approval.
- **Host changes require approval.** Before installing packages (`pip install`) or changing global gcloud or credential state (`gcloud config set ...` such as `auth/impersonate_service_account`, `gcloud auth application-default login` / `set-quota-project`), show the exact command and wait for the user's approval.
- **Never bundle destructive scripts** or delete integrations, versions, connections, or auth profiles during troubleshooting unless the user specifically asks.

## Prerequisites and Setup Check

Before querying APIs, confirm the environment has credentials, active APIs, and the right target region:

```bash
# Verify active identity and project
gcloud config get-value account
gcloud config get-value project

# Check that required APIs are enabled on PROJECT_ID
gcloud services list --enabled --project="PROJECT_ID" \
  --filter="config.name:(integrations.googleapis.com OR connectors.googleapis.com OR secretmanager.googleapis.com)"
```

- If an API is missing, ask the user before running `gcloud services enable integrations.googleapis.com connectors.googleapis.com secretmanager.googleapis.com --project="PROJECT_ID"`.
- Ensure an active billing account is attached to `PROJECT_ID` (required even when usage stays within the monthly free tier; see the [Application Integration pricing page](https://cloud.google.com/application-integration/pricing)).
- For Python discovery clients (install with `pip install "google-api-python-client>=2.100.0,<3" "google-auth>=2.20.0,<3"`) or ADK (`ApplicationIntegrationToolset`), authenticate with `gcloud auth application-default login` and `gcloud auth application-default set-quota-project PROJECT_ID` (changes host or credential state; get the user's approval first).

## Diagnostic Decision Flow

Follow these steps in order whenever a user reports that an integration failed, did nothing, or is stuck.

### Step 1: Confirm Whether an Execution Ran and Check Its True State

Do not rely on an HTTP 200 status from `:execute` as proof that every task succeeded (note: `integrations:test` also exists in the v1 REST API, but its required `TestIntegrationsRequest.clientId` value is not publicly documented, so do not invent one; test by publishing to a non-production project and calling `:execute`). As a diagnostic rule, always check the response payload and execution record because:
- The required verification is the execution record from `executions.list?filter=execution_id="EXECUTION_ID"`—inspect `executionDetails.state`, each task's `taskExecutionState`, and `ErrorInfo` in `responseParameters` (do not rely on the legacy/deprecated `executionFailed` field, which is not a supported public signal).
- If the caller passed `"doNotPropagateError": true` on `:execute`, the API returns HTTP 200 with an `executionId` and places error details inside event parameters instead of returning an HTTP error.
- A duplicate `requestId` on `:execute` or `:schedule` returns the previous execution's response without running a new execution.
- Task failure policies (`IGNORE` and `NONE`) allow an integration to continue or finish as `SUCCEEDED` down an alternate branch even when an individual task failed.

List executions for the integration (use `-` as `INTEGRATION_NAME` to search across all integrations in the region; the discovery doc does not specify whether `orderBy=create_time` sorts ascending or descending, so add a `CreateTimestamp` filter or paginate with `pageToken` if needed):

```bash
curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions?pageSize=10&orderBy=create_time&snapshotMetadataWithoutParams=true"
```

Once you have the `EXECUTION_ID`, fetch its full `ExecutionDetails` and per-task states (use `filter`, `snapshotMetadataWithoutParams=true`, and `readMask` on `executions.list`—never the deprecated `truncateParams` [UI-only] or `filterParams.*` [internal-only] parameters):

```bash
curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions?filter=execution_id%3D%22EXECUTION_ID%22"
```

To filter `executions.list` by state, use the `state` field (`=` or `!=`) with unquoted `ExecutionDetails.state` values (for example, `filter=state=FAILED`, `filter=state!=SUCCEEDED`, `filter=state=CANCELLED`, or `filter=state=FAILED OR state=CANCELLED`, URL-encoded as `filter=state%3DFAILED` or `filter=state%3DFAILED%20OR%20state%3DCANCELLED`); use `state` (not `eventExecutionState`, as shown on the REST reference page, or `event_execution_state` in the API reference's filter description), and use the supported filter keys (`execution_id`, `state`, `update_time`, `workflow_name`, `trigger_id`, `CreateTimestamp`, `parameter_type`)—camelCase variants such as `executionId` are not supported even though some docs examples show them.

### Step 2: What If No Execution Record Exists?

If `executions.list` returns no matching run, check these five causes before assuming the trigger never fired:

| Cause | Symptom | What to verify |
|---|---|---|
| **Wrong region** | Empty list in `LOCATION` | Check `https://console.cloud.google.com/integrations` or list integrations in other regions. |
| **API trigger 403** | Caller got HTTP 403 `PERMISSION_DENIED` | API trigger auth denials fail before execution creation; nothing is written to execution logs. Check caller IAM and `roles/iam.serviceAccountUser` on the run-as service account. |
| **API trigger payload > 8 MB** | Caller got an error | Cumulative API trigger input variables exceed the 8 MB limit, so the integration does not start. |
| **Local logging disabled** | Integration ran, but logs are empty | Check `IntegrationVersion.databasePersistencePolicy` (`DATABASE_PERSISTENCE_DISABLED` = `Disable`; `DATABASE_PERSISTENCE_POLICY_UNSPECIFIED` = `Enable (sync)`, the API default; `DATABASE_PERSISTENCE_ASYNC` = `Enable (async)`, the console default). Also, if total integration data exceeds 10 MB (up to the 30 MB limit), local logging is disabled automatically. |
| **Version not `ACTIVE`** | Trigger never fires | Only an `ACTIVE` (published) version runs from triggers. After publishing, an older version can keep serving for up to 10 minutes due to eventual consistency. |

### Step 3: Branch by Execution State (`ExecutionDetails.state`)

See [Execution States](references/execution-states.md) for the full state reference, task-level states (`TaskExecutionDetails.taskExecutionState`), filter syntax, and cancel/replay rules.

| `ExecutionDetails.state` | Console status | Meaning and next step |
|---|---|---|
| `FAILED` | Failed | Check `ErrorInfo` (`message`, `code`) in `responseParameters`, inspect the failing task's `taskExecutionState` (`FAILED` or `FATAL`), and run Step 4 (`:troubleshoot` and Cloud Logging). |
| `SUCCEEDED` | Succeeded | If expected work did not happen, inspect `taskExecutionDetails` for tasks in `SKIPPED` (edge condition false) or `FAILED` (masked by `IGNORE` or `NONE` retry strategy). |
| `CANCELLED` | Canceled | User canceled the run, a new integration version was published while the run was suspended, a SYNC run hit the 2-minute timeout, or a replayed run hit the 10-minute deadline. |
| `SUSPENDED` | Suspended | Waiting on an Approval task (resolvable in the Cloud console UI or via `suspensions:resolve`) or a Suspend task (resumable via `suspensions:lift`). See [Suspensions](references/suspensions.md). |
| `RETRY_ON_HOLD` | Retry on hold | A task or integration failed with a temporary error and is waiting in the backoff retry queue. |
| `PROCESSING` | In process | Currently running. Check whether an ASYNC run is approaching the 10-minute timeout. |
| `PENDING` | On hold | Scheduled or temporarily paused and waiting to be triggered. |

### Step 4: Inspect Logs, AI Root Cause, and Subsystem Health

1. **Run AI Troubleshoot (v2 REST API)** on a failed execution to get a structured root-cause summary (requires `integrations.executions.get`):
   ```bash
   curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     "https://integrations.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions/EXECUTION_ID:troubleshoot"
   ```
2. **Query Cloud Logging** if Cloud Logging was enabled on the version. Note that Cloud Logging is **disabled by default** and writes nothing if local logging is disabled. See [Logging and Monitoring](references/logging-and-monitoring.md) for how to enable it, severity behavior, and exact queries.
   ```bash
   gcloud logging read \
     'resource.type="integrations.googleapis.com/IntegrationVersion" AND jsonPayload.executionId="EXECUTION_ID"' \
     --project="PROJECT_ID" --limit=20 --format=json
   ```
3. **If a Connectors task failed**, do not guess whether the connector or IAM is at fault. Inspect the connection resource (`connections.get`) and its schema metadata (`GET .../connections/CONNECTION_NAME/connectionSchemaMetadata` for `state` and `errorMessage`, and runtime v2 `GET .../v2/.../connections/CONNECTION_NAME/actions` and `.../entityTypes` for listing—v1 `connectionSchemaMetadata:listActions` and `:listEntityTypes` require a `filter` and reject unfiltered calls). See [Connectors Health](references/connectors-health.md) for connection states, schema metadata checks, and node throttling (HTTP 429).
   ```bash
   curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     "https://connectors.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME?view=FULL"
   ```
4. **If an IAM (403), run-as service account, timeout, or quota error occurred**, check both the caller's role and the integration's run-as service account. Integrations created on or after **October 15, 2026** with any trigger other than an API or Private trigger (for example Schedule, Cloud Scheduler, Cloud Pub/Sub, Salesforce, or Connector Event; Private triggers are exempt like API triggers, so a sub-integration whose only trigger is Private can be published without `runAsServiceAccount`) cannot be tested or published unless `runAsServiceAccount` is set; whenever `runAsServiceAccount` is set, the user publishing or testing the version needs `roles/iam.serviceAccountUser` on it. See [Common Errors](references/common-errors.md) for the two-sided 403 checklist, error codes, task limits, and ADK `ApplicationIntegrationToolset` errors.

## Common Diagnostic Scenarios

### Scenario A: Failed Connectors Task (Connection Health vs Caller IAM)

1. Run `connections.get` with `view=FULL` (command above) and inspect `status.state` and `status.status`.
2. **If `status.state` is `ERROR` or `AUTHORIZATION_REQUIRED`:** the connection itself cannot reach or authenticate to the target backend. Fix the connection's credentials in Secret Manager or the Cloud console (`https://console.cloud.google.com/connectors/connections`). If the connection uses a service account in another project, verify `service-PROJECT_NUMBER@gcp-sa-connectors.iam.gserviceaccount.com` has `roles/iam.serviceAccountTokenCreator` in that project.
3. **If `status.state` is `ACTIVE`:** the connection is healthy. Check whether the identity running the task (the integration's `runAsServiceAccount`, or if unset, `service-PROJECT_NUMBER@gcp-sa-integrations.iam.gserviceaccount.com`) has a required Integration Connectors role (such as `roles/connectors.invoker` or `roles/connectors.admin`) in the connection's project.
4. **If the task failed with HTTP 429:** the connection exceeded its provisioned nodes. Raise min/max nodes on the connection and add a task retry strategy (`EXPONENTIAL_BACKOFF`).
5. **Trace the exact connector attempt in Cloud Logging** (when connector logging is enabled on the connection):
   ```bash
   gcloud logging read \
     'resource.type="connectors.googleapis.com/Connection" AND jsonPayload.integration_connectors_trace_id="EXECUTIONID_TASKID_ATTEMPTNUMBER"' \
     --project="PROJECT_ID" --limit=20 --format=json
   ```

### Scenario B: Stuck in `SUSPENDED` (Approval vs Suspend Task)

1. Identify which task paused the execution from `taskExecutionDetails` and list pending suspensions (read-only; requires `integrations.suspensions.list`, included in `roles/integrations.suspensionResolver`) to find `SUSPENSION_ID` and `taskId`. Note that `roles/integrations.suspensionResolver` alone cannot read execution records (no `integrations.executions.list` or `integrations.executions.get`, returning HTTP 403 on `executions.list` and v2 `:troubleshoot`); to inspect `taskExecutionDetails` (or run `:troubleshoot`), also grant `roles/integrations.integrationViewer` (or use the approval email link, which carries the execution and task IDs). See [Suspensions](references/suspensions.md) for full details.
   ```bash
   # Read-only: list suspensions on EXECUTION_ID
   curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions/EXECUTION_ID/suspensions"
   ```
2. **Approval task:** can be approved or rejected in the Cloud console UI or via the REST API (`POST https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions/EXECUTION_ID/suspensions/SUSPENSION_ID:resolve` with body `{"suspension": {"eventExecutionInfoId": "EXECUTION_ID", "integration": "INTEGRATION_NAME", "taskId": "TASK_ID", "state": "LIFTED"}}` or `"REJECTED"`—the same call the console Approve/Reject buttons make). Always confirm with the user before resolving. Verify the caller holds `integrations.suspensions.resolve` (included in `roles/integrations.suspensionResolver`, which is not included in `roles/integrations.integrationEditor`) **and** `roles/iam.serviceAccountUser` on the integration's `runAsServiceAccount`. Without `roles/iam.serviceAccountUser`, approving leaves the execution paused until it expires.
3. **Suspend task:** `:lift` is the Suspend-task variant and requires `integrations.suspensions.lift` (included in `roles/integrations.suspensionResolver`) plus `roles/iam.serviceAccountUser` on the integration's `runAsServiceAccount`. After user confirmation, call `POST .../executions/EXECUTION_ID/suspensions/SUSPENSION_ID:lift` with an optional `suspensionResult`.
4. **Watch out for version publish cancellation:** publishing a new version of an integration automatically cancels all suspended executions of the previous version.

### Scenario C: HTTP 403 `PERMISSION_DENIED` on Trigger, Test, or Publish

Application Integration enforces two independent permission checks:
1. **Caller IAM check:** the caller needs permission on the integration (`roles/integrations.integrationInvoker` to invoke, `roles/integrations.integrationEditor` to edit/test, `roles/integrations.integrationDeployer` or `roles/integrations.integrationEditor` to publish).
2. **Run-as service account check:** whenever `runAsServiceAccount` is set on the version, the user (or principal) publishing or testing the version needs `roles/iam.serviceAccountUser` on `runAsServiceAccount` at publish/test time, and at runtime the invoking caller or trigger service account needs `roles/iam.serviceAccountUser` on `runAsServiceAccount` (granted in the project that owns the service account). In addition, `runAsServiceAccount` needs roles on downstream Google Cloud resources.

Check both bindings before retrying. For Pub/Sub, Eventarc, and Connector Event triggers, a run-as service account (`roles/iam.serviceAccountUser`) denial records a failed execution and the event is **not** redelivered.

## Recovery Actions (Require User Confirmation)

Always display the exact command and obtain user confirmation before running `:cancel`, `:replay`, `:lift`, or `:resolve`. `:cancel` requires `integrations.executions.cancel` and `:replay` requires `integrations.executions.replay` (both are held by `roles/integrations.integrationInvoker`, `roles/integrations.integrationEditor`, and `roles/integrations.integrationAdmin`—**not** by `roles/integrations.suspensionResolver` or `roles/integrations.integrationViewer`, so approvers with only `roles/integrations.suspensionResolver` cannot cancel a stuck `SUSPENDED` run). `:replay` also enforces two preconditions that return `FAILED_PRECONDITION`: (a) test-case runs cannot be replayed in any mode (`"Test runs cannot be replayed."`), and (b) `REPLAY_MODE_POINT_OF_FAILURE` is refused for executions that ran with database persistence (local logging / `databasePersistencePolicy: DATABASE_PERSISTENCE_DISABLED`) disabled because it needs execution snapshots—use `REPLAY_MODE_FROM_BEGINNING` in that case. When overriding inputs on `:replay` with `modifiedParameters` and `updateMask`, list every overridden key in `updateMask`; without `updateMask`, all original inputs are discarded and only `modifiedParameters` are used, and a key in `updateMask` missing from `modifiedParameters` is an error.

```bash
# Cancel an execution in PENDING (console "On hold"), RETRY_ON_HOLD, or SUSPENDED state (requires integrations.executions.cancel)
# (Cannot cancel executions in PROCESSING state [console "In process"], completed runs [SUCCEEDED, FAILED, CANCELLED], or Schedule-trigger runs; approvers with only roles/integrations.suspensionResolver cannot cancel a stuck SUSPENDED run)
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{"cancelReason": "Canceling stuck execution after investigation"}' \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions/EXECUTION_ID:cancel"

# Replay a SUCCEEDED, FAILED, or CANCELLED execution on a published integration (Preview; requires integrations.executions.replay; test-case runs and Schedule-trigger runs cannot be replayed)
# replayMode: REPLAY_MODE_FROM_BEGINNING or REPLAY_MODE_POINT_OF_FAILURE (failed runs only; refused with FAILED_PRECONDITION if databasePersistencePolicy was DATABASE_PERSISTENCE_DISABLED—use REPLAY_MODE_FROM_BEGINNING in that case)
# Optional modifiedParameters/updateMask: list every overridden key in updateMask; without updateMask, all original inputs are discarded and only modifiedParameters are used; a key in updateMask missing from modifiedParameters is an error
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{"replayReason": "Replay after fixing downstream permission", "replayMode": "REPLAY_MODE_POINT_OF_FAILURE"}' \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions/EXECUTION_ID:replay"
```

## Reference Files

Load the matching reference file when you need deeper details, exact field names, or edge-case checks:

- [Usage Attribution](references/attribution.md): Usage attribution for `gcloud` CLI commands, direct `curl` REST calls, and Python discovery-client snippets run in the terminal.
- [Execution States](references/execution-states.md): `ExecutionDetails.state` and `TaskExecutionDetails.taskExecutionState` enums, `executions.list` filter operators, large-log workarounds (> 300 MB), and `:cancel` / `:replay` constraints.
- [Logging and Monitoring](references/logging-and-monitoring.md): Local logging vs Cloud Logging interactions, enabling Cloud Logging on a draft version, Logs Explorer queries, `integrations.googleapis.com/*` and `connectors.googleapis.com/*` metric schemas, and alerting setup.
- [Common Errors](references/common-errors.md): HTTP/gRPC error codes, the two-sided 403 checklist, the October 15, 2026 run-as service account requirement, task-level limits and gotchas, and ADK `ApplicationIntegrationToolset` errors.
- [Connectors Health](references/connectors-health.md): `ConnectionStatus.state`, `EventingStatus.state`, `connectionSchemaMetadata` probes, runtime v2 readiness calls, node throttling (HTTP 429), and separating connection auth from caller IAM.
- [Suspensions](references/suspensions.md): Suspend vs Approval vs Timer behavior, `suspensions.list` / `:lift` / `:resolve` payloads, expiration settings, and why approvals stay stuck without `roles/iam.serviceAccountUser`.
references/
attribution.md 5.0 KB
# Usage Attribution

**MUST READ**: Before executing any `gcloud` command, REST API call, or Python
discovery-client call with this skill, follow these usage attribution
instructions. Tag every command you execute directly in the terminal so usage
can be attributed. The tag identifies only the skill and its version; it carries
no user data.

-   **`gcloud` CLI Commands**: Prefix every `gcloud` invocation, whatever the
    subcommand (in this skill, generic tasks such as enabling APIs, IAM, and
    `gcloud logging read`), with the metrics environment variable. Set it inline
    on each command because shell state may not persist between commands:

    ```bash
    CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:application-integration-troubleshooting)" \
    gcloud <command> [flags]
    ```

    Do not use `gcloud config set` for this: it would persist beyond the current
    task and mislabel unrelated usage. `gcloud auth print-access-token` never
    needs the prefix, whether it runs on its own (for example to check
    credentials), inline as `$(gcloud auth print-access-token)`, or assigned
    first, as in `TOKEN="$(gcloud auth print-access-token)"`: it only fetches a
    credential, and the `curl` requests that use the token carry the attribution
    `User-Agent` header themselves. Every other `gcloud` command you run needs
    the prefix, including read-only and local ones such as
    `gcloud services list` or `gcloud config list`.

-   **Direct HTTP and REST Requests (`curl`)**: Application Integration has no
    Google-managed MCP server and no `gcloud integrations` command group; calls
    go to `https://integrations.googleapis.com/v1/...` (and
    `https://connectors.googleapis.com/...`). Add the header
    `-H "User-Agent: agent-skills/1.0 (skill:application-integration-troubleshooting)"`
    to every `curl` call you run directly. `curl` sends its own default
    `User-Agent` (`curl/<version>`) only when none is given, so an explicit
    `-H "User-Agent: ..."` replaces it; if a `User-Agent` header is already
    specified, append this string to the end of it rather than overwriting
    existing `User-Agent` data — the collection pipeline parses the
    `agent-skills/<version>` and `skill:<name>` tokens, so any rewording breaks
    attribution:

    ```bash
    curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      -H "User-Agent: agent-skills/1.0 (skill:application-integration-troubleshooting)" \
      "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations"
    ```

-   **Python discovery client run directly by you**: When you yourself run a
    one-off Python snippet in the terminal that uses
    `googleapiclient.discovery.build("integrations", "v1")` (or
    `build("connectors", "v1")`), wrap the authorized HTTP object with
    `googleapiclient.http.set_user_agent`, which adds the given string to the
    `User-Agent` header of every request made through that object (the client
    library's own `(gzip)` marker stays after it). Use this pattern
    (`google-auth-httplib2` is installed as a dependency of
    `google-api-python-client`):

    ```python
    import google.auth
    import google_auth_httplib2
    from googleapiclient import discovery
    from googleapiclient.http import set_user_agent

    credentials, _ = google.auth.default(
        scopes=["https://www.googleapis.com/auth/cloud-platform"]
    )
    http = set_user_agent(
        google_auth_httplib2.AuthorizedHttp(credentials),
        "agent-skills/1.0 (skill:application-integration-troubleshooting)",
    )
    service = discovery.build("integrations", "v1", http=http)
    ```

    Do not pass both `http=` and `credentials=` to `build`; because `http=`
    bypasses the scoping `build` normally applies, request the
    `https://www.googleapis.com/auth/cloud-platform` scope in
    `google.auth.default` as shown.

-   **Constraint for Generated Code**: The tracking prefix, `User-Agent` header,
    and `set_user_agent` wrapper are strictly for commands you execute directly
    in the terminal. Do NOT include them in code provided to the user for their
    own repositories, including generated scripts, CI/CD pipelines, Terraform
    configurations, ADK agents (including `ApplicationIntegrationToolset` code),
    Python modules, or integration version JSON.

-   **No host or credential changes**: The attribution is per command only. It
    is not a host change and does not need the approval required by the skill's
    "Host changes require approval" rule, because it never persists anything.
    Never persist it with `gcloud config set metrics/request_attribution`, by
    exporting the variable in a shell profile, or in `~/.curlrc`; those would be
    host changes (needing the user's approval under that rule) and would
    mislabel unrelated usage.

-   **User Opt-Out**: If the user asks to disable or remove tracking or
    attribution tags, omit the `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION` variable,
    custom `User-Agent` suffix, and `set_user_agent` wrapper from all commands.
common-errors.md 16.7 KB
# Common Errors: IAM, Run-As Service Account, Quotas, Tasks, and ADK

Use this reference to diagnose HTTP/gRPC error codes, 403 permission denials, the October 15, 2026 run-as service account requirement, missing APIs, quotas and timeouts, task gotchas, and ADK `ApplicationIntegrationToolset` errors.

- [HTTP and gRPC Error Codes](#http-and-grpc-error-codes): Lines 13-27
- [Two-Sided 403 `PERMISSION_DENIED` Diagnosis](#two-sided-403-permission_denied-diagnosis): Lines 28-70
- [October 15, 2026 Run-As Service Account Requirement](#october-15-2026-run-as-service-account-requirement): Lines 71-80
- [APIs Not Enabled](#apis-not-enabled): Lines 81-90
- [Quotas, Timeouts, and Data Limits](#quotas-timeouts-and-data-limits): Lines 91-106
- [Task-Specific Configuration Gotchas](#task-specific-configuration-gotchas): Lines 107-118
- [ADK (`ApplicationIntegrationToolset`) Troubleshooting](#adk-applicationintegrationtoolset-troubleshooting): Lines 119-129

## HTTP and gRPC Error Codes

| HTTP | `google.rpc.Code` | Common cause in Application Integration |
|---|---|---|
| `400` | `FAILED_PRECONDITION` / `INVALID_ARGUMENT` | Invalid request payload, parameter type mismatch, or failed precondition. |
| `401` | `UNAUTHENTICATED` | Missing, invalid, or expired OAuth access token. Refresh with `gcloud auth print-access-token`. |
| `403` | `PERMISSION_DENIED` | Missing caller IAM role, missing `roles/iam.serviceAccountUser` on the run-as service account, run-as SA missing downstream access, wrong OAuth scope, or required API not enabled. |
| `404` | `NOT_FOUND` | Wrong `PROJECT_ID`, `LOCATION`, `INTEGRATION_NAME`, `VERSION_ID`, or `CONNECTION_NAME`. |
| `409` | `ALREADY_EXISTS` | Resource already exists. |
| `409` | `ABORTED` | `Response size is too large`. |
| `429` | - | Integration Connectors connection exceeded its provisioned nodes (throttling). |
| `500` | `INTERNAL` | Often caused when a task or trigger in the integration is misconfigured. Check per-task `ErrorInfo` and task parameters. |
| `501` | `UNIMPLEMENTED` | API method not implemented by the server. |
| `503` | `UNAVAILABLE` | Transient backend or network unavailability; retry with backoff. |

## Two-Sided 403 `PERMISSION_DENIED` Diagnosis

Every integration run evaluates **two separate identities**. Fixing only one leaves the 403 in place.

1. **Caller / trigger identity** (the user or service account calling `:execute`, `:schedule`, `:publish`, or firing the trigger).
2. **Run-as service account** (`IntegrationVersion.runAsServiceAccount`, or the default Application Integration service agent `service-PROJECT_NUMBER@gcp-sa-integrations.iam.gserviceaccount.com` on older integrations without one).

### Required IAM Roles by Action

| Action | Required role on caller | Additional role when `runAsServiceAccount` is set |
|---|---|---|
| View integration | `roles/integrations.integrationViewer` | - |
| View execution logs | `roles/integrations.integrationViewer` or `roles/integrations.integrationInvoker` (**not** in `roles/integrations.suspensionResolver`) | - |
| Run / invoke (`:execute`, `:schedule`) | `roles/integrations.integrationInvoker`, `roles/integrations.integrationEditor`, or `roles/integrations.integrationAdmin` (`integrations.integrations.invoke`) | `roles/iam.serviceAccountUser` on `runAsServiceAccount` |
| Replay execution (`:replay`) | `roles/integrations.integrationInvoker`, `roles/integrations.integrationEditor`, or `roles/integrations.integrationAdmin` (`integrations.executions.replay`; **not** in `roles/integrations.suspensionResolver` or `roles/integrations.integrationViewer`) | `roles/iam.serviceAccountUser` on `runAsServiceAccount` |
| Cancel execution (`:cancel`) | `roles/integrations.integrationInvoker`, `roles/integrations.integrationEditor`, or `roles/integrations.integrationAdmin` (`integrations.executions.cancel`; **not** in `roles/integrations.suspensionResolver` or `roles/integrations.integrationViewer`, so approvers with only `roles/integrations.suspensionResolver` cannot cancel a stuck `SUSPENDED` run) | - |
| Edit or test draft | `roles/integrations.integrationEditor` | `roles/iam.serviceAccountUser` on `runAsServiceAccount` (for the user testing the version) |
| Publish / unpublish | `roles/integrations.integrationDeployer` or `roles/integrations.integrationEditor` (plus `roles/integrations.serviceAgent` on the Application Integration service agent) | `roles/iam.serviceAccountUser` on `runAsServiceAccount` (for the user publishing the version) |
| List, approve (`:resolve`), or lift (`:lift`) suspension | `roles/integrations.suspensionResolver` or `roles/integrations.integrationAdmin` (`integrations.suspensions.list` for `suspensions.list`, `integrations.suspensions.resolve` for `:resolve` [Approval], `integrations.suspensions.lift` for `:lift` [Suspend]). `roles/integrations.suspensionResolver` alone cannot read execution records (no `integrations.executions.list` or `integrations.executions.get`, returning HTTP 403 on `executions.list` and v2 `:troubleshoot`); to inspect `taskExecutionDetails` (or run `:troubleshoot`), also grant `roles/integrations.integrationViewer` (or use the approval email link, which carries the execution and task IDs). | `roles/iam.serviceAccountUser` on `runAsServiceAccount` |

### Typical Error Message and Trigger Behavior

Typical error:
`PRINCIPAL needs roles/iam.serviceAccountUser on SERVICE_ACCOUNT (or its project) to run this integration.`

How each trigger surfaces a run-as service account (`roles/iam.serviceAccountUser`) 403:
- **API trigger (`:execute`):** returns HTTP 403 directly to the caller. **Nothing appears in Execution Logs.**
- **Cloud Pub/Sub, Eventarc, and Connector Event triggers:** records a `FAILED` execution in logs, and **the event is not redelivered**.
- **Cloud Scheduler trigger:** reports `PERMISSION_DENIED` in Cloud Scheduler logs.

### Why a 403 Persists After Granting IAM

- **Wrong project:** `roles/iam.serviceAccountUser` must be granted on the service account (or in the project that **owns** that service account), not necessarily the integration's project.
- **Propagation delay:** IAM binding changes take a short time to propagate.
- **Second service account:** an authentication profile (`authConfig`) or a called sub-integration uses a different service account.
- **Wrong trigger principal:** for Cloud Scheduler, Cloud Pub/Sub, Eventarc, or Integration Connectors event triggers, the principal that needs `roles/iam.serviceAccountUser` is the trigger's service account, not your user account.
- **IAM conditions:** a condition on the binding does not match the integration resource.

```bash
# Inspect IAM policy on the run-as service account (read-only)
gcloud iam service-accounts get-iam-policy "RUN_AS_SA_EMAIL" --project="SA_OWNER_PROJECT_ID"
```

## October 15, 2026 Run-As Service Account Requirement

- **Rule:** For integrations created on or after **October 15, 2026** (and for existing integrations at a later date), every execution requires an explicit identity (either the triggering user or a run-as service account set per integration version via `IntegrationVersion.runAsServiceAccount`; region provisioning via `clients:provision` does not apply `runAsServiceAccount`).
- **Triggers other than API or Private:** Integrations created on or after **October 15, 2026** with any trigger other than an API or Private trigger (for example Schedule, Cloud Scheduler, Cloud Pub/Sub, Salesforce, or Connector Event) cannot be tested or published unless `runAsServiceAccount` is set (Private triggers are exempt like API triggers, so a sub-integration whose only trigger is Private can be published without `runAsServiceAccount`); whenever `runAsServiceAccount` is set on a version, the user publishing or testing the version needs `roles/iam.serviceAccountUser` on it (and at runtime, the invoking caller or trigger service account needs `roles/iam.serviceAccountUser` on it).
- **Governance mode:** If governance is enabled on the region, a run-as service account is mandatory for all new integrations and versions regardless of trigger type.
- **Token precedence on tasks:** For Connector, Call REST Endpoint, and Cloud Function tasks:
  1. If an OAuth 2.0 / OIDC authentication profile (`authConfig`) is attached to the task, it takes precedence.
  2. Otherwise, if `runAsServiceAccount` is set on the version, it mints the token.
  3. On legacy integrations with neither set, the default Application Integration service agent (`service-PROJECT_NUMBER@gcp-sa-integrations.iam.gserviceaccount.com`) is used.

## APIs Not Enabled

Missing APIs surface as HTTP 403 `PERMISSION_DENIED`.

- **Application Integration core:** `integrations.googleapis.com`, `secretmanager.googleapis.com`, `connectors.googleapis.com`
- **CMEK regions:** `cloudkms.googleapis.com`
- **Cloud Scheduler triggers:** `cloudscheduler.googleapis.com`

Ask the user for confirmation before enabling any missing API with `gcloud services enable`.

## Quotas, Timeouts, and Data Limits

| Limit / Quota | Value | Failure symptom |
|---|---|---|
| **SYNC execution timeout** | 2 minutes | Status becomes `CANCELLED` after 2 minutes (includes external calls and sub-integrations). |
| **ASYNC execution timeout** | 10 minutes | Execution fails or cancels at 10 minutes. |
| **`:execute` HTTP timeout** | 120 seconds default | Controlled by `X-Server-Timeout` request header. |
| **Max execution lifetime** | 31 days (44,640 min) | Includes time paused in Approval or Suspend tasks. |
| **Concurrent executions** | 50 per project per region; 10 per integration (defaults) | Both caps are adjustable. A burst on a single integration hits the 10-per-integration cap, not 50. Backoff retry concurrency also defaults to 50 per project and region. |
| **Execution rate** | Shown on Cloud Quotas page | The execution request rate quota is shown on the Cloud Quotas page for the project and can be adjusted there. |
| **Execution-log reads** | 18,000 reads / minute | Rate limit on reading execution logs. |
| **Max cumulative integration data** | 30 MB | Shared between parent and Private-trigger sub-integration. Above 10 MB, local logging is disabled. |
| **API trigger input size** | 8 MB | Cumulative input variables > 8 MB prevent execution from starting. |
| **Connectors task timeout & size** | 3 minutes; 8 MB to/from connection (Application Integration quota) | Max 10 MB Connectors task payload (Integration Connectors quota); max 20 MB connector response; custom query max 180 s and 50,000 rows. |
| **Publish eventual consistency** | Up to 10 minutes | An older published version can keep running for up to 10 minutes after publishing a new version. |

## Task-Specific Configuration Gotchas

- **Call REST Endpoint:** reaches public internet hosts only (no VPC-private hosts); fails on HTTP 4xx/5xx; max 20 MB request and 34 MB response; max 100 concurrent calls. **Gotcha:** if you change the task's authentication profile, publish the version before testing (for example, in a non-production project via `:execute`) so the updated profile takes effect.
- **Cloud Function task:** stops working if VPC Service Controls is enabled for Application Integration; an OIDC profile overrides a user-managed service account; function code must follow the required `main.py` / `task.py` template.
- **Data Mapping task:** input and output types must match (use `TO_STRING`, `TO_INT`, etc.); null inputs cause an error unless a fallback value is configured; arrays max 100,000 elements; JSON/string variables max 20 MB.
- **Data Transformer Script (Preview):** Jsonnet identifiers cannot contain hyphens; 300 MB evaluation memory limit.
- **JavaScript task:** Rhino is deprecated (use V8); do not delete `executesScript(event)`; max 25 MB script request size.
- **Private trigger:** cannot test a published Private-trigger workflow (unpublish it first to test, or call it from a parent integration).
- **Call Integration / Loops:** callee must have an API trigger or a Private trigger (Private triggers are invokable only from other integrations); caller SA needs `roles/integrations.integrationInvoker`. Child responses/output parameters are returned to the parent only in SYNC mode (ASYNC calls return no output parameters). For Each Loop and While Loop max 8,000 iterations. For Each Parallel max 10,000 iterations (default parallelism 50); avoid SYNC mode if the sub-integration takes > 2 minutes or has an Approval task; choosing "run all integrations with this trigger ID" makes sub-integration responses unavailable.
- **Error Catcher:** cannot nest error catchers; only one catcher per task or trigger; cannot draw edges from error catcher tasks back into the main workflow.
- **Config variables:** stored in plain text on download and template export (not a secret store; use an auth profile or Secret Manager task for credentials). Keys in `configParameters` on `versions:publish` must **exactly match** a key in `integrationConfigParameters`, backticks included (for example, `` "`CONFIG_target_url`" ``); unknown keys are **silently ignored**, not rejected (`versions:publish` returns 200 and the default stays). Cannot parameterize connector entity operations or actions.

## ADK (`ApplicationIntegrationToolset`) Troubleshooting

| Error / Symptom | Cause | Fix |
|---|---|---|
| `ValueError: Invalid request, Either integration or (connection and (entity_operations or actions)) should be provided.` | Missing constructor arguments in Python (in Java, `IllegalArgumentException` is emitted via `Flowable.error` from `getTools()`). | Pass `integration="..."` and `triggers=["api_trigger/..."]` (or `triggers=[]` for all API triggers; omitting `triggers` raises `Exception: An unexpected error occurred: Integration name and triggers are required to generate an integration OpenAPI spec.`), or pass `connection="..."` with `entity_operations` or `actions`. |
| `ValueError: Invalid request. Please check the provided values of project(...), location(...), integration\|connection(...)` | Underlying API returned HTTP 400 or 404. | Verify `project`, `location`, and resource names. For connector mode, Application Integration must be provisioned in the **same region** as the connection. |
| `Exception: An unexpected error occurred: Please provide a service account that has the required permissions to access the connection.` | Application Default Credentials (ADC) missing or expired. | Run `gcloud auth application-default login` (changes host or credential state; get the user's approval first), or pass `service_account_json`. |
| HTTP 403 in integration mode or connection mode (anywhere the agent runs, including Agent Runtime) | Required IAM roles depend on mode. **Integration mode**: `ApplicationIntegrationToolset` fetches the tool schema via `POST .../locations/LOCATION:generateOpenApiSpec`, which requires `integrations.integrations.generateOpenApiSpec` (`roles/integrations.integrationViewer` and `roles/integrations.integrationEditor` include it; `roles/integrations.integrationInvoker` does **not**, so `integrationInvoker` alone fails with 403 wherever the agent runs). **Connection mode**: When constructed and using the agent's own credentials, the toolset calls `GET .../connections/CONNECTION?view=BASIC`, `connectionSchemaMetadata:getEntityType`, and `connectionSchemaMetadata:getAction`, which require `connectors.connections.get` and `connectors.connections.getConnectionSchemaMetadata` (`roles/connectors.viewer` has both; `roles/connectors.invoker` does **not**, and `roles/integrations.integrationEditor` holds no `connectors.*` permissions). Connection mode does **not** call `:generateOpenApiSpec`. | **Integration mode**: grant `roles/integrations.integrationInvoker` + `roles/integrations.integrationViewer` (`roles/integrations.integrationEditor` only as the broad option—it also grants version create/update/delete/publish and holds no `connectors.*` permissions). **Connection mode**: grant `roles/integrations.integrationInvoker` (to `:execute` the `ExecuteConnection` integration) + `roles/connectors.viewer` (or a custom role with `connectors.connections.get` and `connectors.connections.getConnectionSchemaMetadata`; `integrationViewer` is only needed in integration mode). `roles/secretmanager.secretAccessor` is not needed for the toolset itself (the ADK client does not read Secret Manager). |
| Connector mode fails to find workflow | Missing `ExecuteConnection` integration. | Connector mode requires a published integration named `ExecuteConnection` (created from the Connection Tool template) in the connection's region, or `connection_template_override` (ADK Python v1.21.0+). |
| `tool_name_prefix` / `tool_instructions` ignored | Passed with `integration=...`. | Those parameters apply only when passing `connection=...`; on the `integration=` path they are silently ignored. |
| Dynamic OAuth (`auth_scheme` / `auth_credential`) ignored | Connection lacks override support. | Enable `authOverrideEnabled` on the Integration Connectors connection; otherwise ADK logs a warning and ignores dynamic credentials. |
connectors-health.md 10.4 KB
# Integration Connectors Health and Schema Troubleshooting

Use this reference when a Connectors task or Connector Event trigger fails. It separates broken connections (`ERROR`, `AUTHORIZATION_REQUIRED`, `INACTIVE`, schema failures, node throttling) from caller IAM failures (a Connectors role such as `roles/connectors.invoker` or `roles/connectors.admin`).

- [Diagnostic Decision Flow: Connection vs Caller IAM](#diagnostic-decision-flow-connection-vs-caller-iam): Lines 12-21
- [Step 1: Check Connection State (`connections.get`)](#step-1-check-connection-state-connectionsget): Lines 22-39
- [Step 2: Check Eventing State (Connector Event Triggers)](#step-2-check-eventing-state-connector-event-triggers): Lines 40-59
- [Step 3: Check Schema Metadata and Runtime Readiness](#step-3-check-schema-metadata-and-runtime-readiness): Lines 60-96
- [Step 4: Separate Connection Auth from Caller IAM](#step-4-separate-connection-auth-from-caller-iam): Lines 97-109
- [Step 5: Check Throttling (HTTP 429) and Connectors Limits](#step-5-check-throttling-http-429-and-connectors-limits): Lines 110-131

## Diagnostic Decision Flow: Connection vs Caller IAM

1. **Fetch the connection resource** with `view=FULL` (`connections.get`).
2. **Check `status.state`:**
   - If `ERROR`, `AUTHORIZATION_REQUIRED`, `INACTIVE`, `CREATING`, `UPDATING`, or `DELETING`, the connection itself is not ready. Fix the connection first.
   - If `ACTIVE`, the connection is up and ready for requests.
3. **If `ACTIVE` and using a Connector Event trigger,** check `eventingStatus.state` (`ACTIVE` vs `ERROR` or `INGRESS_ENDPOINT_REQUIRED`).
4. **If `ACTIVE` and an entity or action fails,** check `connectionSchemaMetadata` (`state` and `errorMessage`) and runtime v2 `checkStatus` / `checkReadiness`.
5. **If the connection and schema are healthy,** check caller IAM (a Connectors role such as `roles/connectors.invoker` or `roles/connectors.admin` on the integration's run-as service account) and task payload/timeout limits.

## Step 1: Check Connection State (`connections.get`)

`GET https://connectors.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME` returns `ConnectionStatus` under `status`. Pass `view=FULL` (default is `BASIC`) to inspect full configuration and status details.

```bash
curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://connectors.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME?view=FULL"
```

| `ConnectionStatus.state` | Meaning | Next step |
|---|---|---|
| `ACTIVE` | Running and ready for requests. | Proceed to Step 2 (schema/eventing) or Step 4 (caller IAM). |
| `ERROR` | Not running due to an error. | Read `status.status` for the detailed error message. Check target host reachability, Endpoint Attachment / Managed Zone (for private backends), and Secret Manager credentials. |
| `AUTHORIZATION_REQUIRED` | Authorization configuration is incomplete. | Complete OAuth authorization or credential setup in `https://console.cloud.google.com/connectors/connections`. |
| `INACTIVE` | Connection is stopped / suspended. | Resume the connection in the Cloud console, or set `suspended: false` via `connections.patch` with `updateMask=suspended` (requires user confirmation). |
| `CREATING` / `UPDATING` | Provisioning or update in progress. | Wait for `ACTIVE` before running tasks. |
| `DELETING` | Being deleted. | Update the integration to point to an active connection. |

## Step 2: Check Eventing State (Connector Event Triggers)

For integrations started by a Connector Event trigger, inspect `eventingStatus.state` on the connection response:

| `EventingStatus.state` | Meaning |
|---|---|
| `ACTIVE` | Event subscriptions are active. |
| `ERROR` | Eventing failed. You can attempt repair via `:repairEventing` (after user confirmation). |
| `INGRESS_ENDPOINT_REQUIRED` | Ingress endpoint configuration is missing for event delivery. |

To repair event subscriptions (state-changing; show command and get user confirmation first):

```bash
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{}' \
  "https://connectors.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME:repairEventing"
```

## Step 3: Check Schema Metadata and Runtime Readiness

If `ConnectionStatus.state` is `ACTIVE` but the Connectors task cannot find or run an entity or action, inspect `connectionSchemaMetadata` (for `state` and `errorMessage`) and list available actions or entity types via the runtime v2 API.

```bash
# Primary probe for schema state and errorMessage on CONNECTION_NAME (read-only, no filter)
curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://connectors.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME/connectionSchemaMetadata"

# List discovered actions via runtime v2 actions.list (read-only)
curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://connectors.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME/actions"

# List discovered entity types via runtime v2 entityTypes.list (read-only)
curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://connectors.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME/entityTypes"
```

- **Why use `GET .../connectionSchemaMetadata` and runtime v2 `actions.list` / `entityTypes.list`:** `GET https://connectors.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME/connectionSchemaMetadata` (no filter) is the primary probe for `state` and `errorMessage`. For listing actions and entity types, use runtime v2 `actions.list` (`GET https://connectors.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME/actions`) and `entityTypes.list` (`GET https://connectors.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME/entityTypes`)—the v1 `connectionSchemaMetadata:listActions` and `connectionSchemaMetadata:listEntityTypes` methods **require** a `filter` query parameter (calls without a filter are rejected, and wildcards are not supported).
- **Schema states (`ConnectionSchemaMetadata.state`):** `STATE_UNSPECIFIED`, `REFRESHING`, `UPDATED`, `REFRESHING_SCHEMA_METADATA`, `UPDATED_SCHEMA_METADATA`, `REFRESH_SCHEMA_METADATA_FAILED` (check `errorMessage`), `REFRESHING_FULL_SCHEMA`, `UPDATED_FULL_SCHEMA`.
- **Additional read methods:** `:getEntityType` and `:getAction`.
- **Refresh schema (state-changing; ask user confirmation first):**
  ```bash
  curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    -d '{}' \
    "https://connectors.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME/connectionSchemaMetadata:refresh"
  ```

### Runtime v2 Health Probes

The Integration Connectors v2 data-plane API (`https://connectors.googleapis.com/v2/...`) exposes direct runtime checks on a connection:
- `GET .../v2/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME:checkStatus`
- `GET .../v2/projects/PROJECT_ID/locations/LOCATION/connections/CONNECTION_NAME:checkReadiness`
- It also exposes `actions.list`, `actions.get`, `entityTypes.list`, `entityTypes.get`, entity CRUD (`entities.list`/`get`/`create`/`patch`/`delete`), `connections:executeSqlQuery`, and `connections/CONNECTION_NAME/actions/ACTION_NAME:execute` (ask user confirmation before running write actions or SQL queries).

## Step 4: Separate Connection Auth from Caller IAM

A connection has two independent authentication hops:

| Hop | Principal | Where credentials / roles live | Symptom when broken |
|---|---|---|---|
| **1. Caller -> Connection** | Integration's `runAsServiceAccount` (or default `service-PROJECT_NUMBER@gcp-sa-integrations.iam.gserviceaccount.com` if none set) | IAM in the connection's Google Cloud project (a Connectors role such as `roles/connectors.invoker` or `roles/connectors.admin`). | Connection `status.state` is `ACTIVE`, but the Connectors task fails with HTTP 403 `PERMISSION_DENIED`. |
| **2. Connection -> Target backend** | Connection's own configured auth (Secret Manager secret, OAuth token, or connection service account) | Connection config in Integration Connectors + target SaaS/DB. | `ConnectionStatus.state` is `ERROR` or `AUTHORIZATION_REQUIRED`, or v2 `checkStatus` fails. |

### Cross-Project Service Account on a Connection

If a connection itself is configured to act as a service account from **another** Google Cloud project, the Integration Connectors service agent (`service-PROJECT_NUMBER@gcp-sa-connectors.iam.gserviceaccount.com`) must hold `roles/iam.serviceAccountTokenCreator` on that service account in the other project.

## Step 5: Check Throttling (HTTP 429) and Connectors Limits

### Node Throttling (HTTP 429)

- Each connection scales between its configured minimum and maximum nodes (up to 100 nodes per connection; up to 50 connections per region and 20 unique regions).
- When traffic exceeds the connection's active node capacity, requests fail with **HTTP 429**.
- **Remediation:**
  1. Check `connectors.googleapis.com/connection/nodes` and `connection/response_count` (filtered by `code="429"`) in Cloud Monitoring.
  2. Raise the minimum or maximum node count on the connection. Note that an active billing account must be attached to the project even when usage stays within the monthly free tier, and additional nodes beyond the free tier incur charges; check the [Application Integration pricing page](https://cloud.google.com/application-integration/pricing) and the Google Cloud Pricing Calculator before scaling nodes.
  3. Configure a task retry strategy (such as `EXPONENTIAL_BACKOFF`) on the Connectors task in the integration.

### Connectors Task Limits

| Limit | Value |
|---|---|
| **Connectors task timeout** | 3 minutes |
| **Data sent to / from a connection** | 8 MB max (Application Integration quota) |
| **Maximum Connectors task payload** | 10 MB (Integration Connectors quota) |
| **Maximum connector response** | 20 MB |
| **Execute Custom Query timeout / rows** | 180 seconds / 50,000 rows max |
| **List entities pagination** | Default page size 25, max 50,000 pages |
| **Cross-region support** | An integration and the connection it calls can be in different regions (except ADK `ApplicationIntegrationToolset` connection mode, which requires the same region). |
execution-states.md 14.4 KB
# Execution States, Listing Filters, Cancel, and Replay

Use this reference to interpret execution-level and task-level states, inspect executions through `executions.list`, run v2 AI troubleshooting, and safely cancel or replay runs.

- [Why HTTP 200 Does Not Prove Every Task Succeeded](#why-http-200-does-not-prove-every-task-succeeded): Lines 13-32
- [Execution-Level States (`ExecutionDetails.state`)](#execution-level-states-executiondetailsstate): Lines 33-47
- [Execution Methods (`Execution.executionMethod`)](#execution-methods-executionexecutionmethod): Lines 48-58
- [Task-Level States (`TaskExecutionDetails.taskExecutionState`)](#task-level-states-taskexecutiondetailstaskexecutionstate): Lines 59-78
- [Listing and Filtering Executions (`executions.list`)](#listing-and-filtering-executions-executionslist): Lines 79-121
- [AI Troubleshooting (`v2` `executions:troubleshoot`)](#ai-troubleshooting-v2-executionstroubleshoot): Lines 122-134
- [Canceling and Replaying Executions](#canceling-and-replaying-executions): Lines 135-179

## Why HTTP 200 Does Not Prove Every Task Succeeded

An HTTP 200 return from `integrations.execute` means the synchronous API request finished, not necessarily that every task in the workflow succeeded. Treat HTTP 200 as a transport status and always check the payload and execution record:

- **Inspect the execution record (`executions.list`):** Query `executions.list?filter=execution_id="EXECUTION_ID"` and check `executionDetails.state` and each task's `taskExecutionState` in `executionSnapshots` (do not rely on the legacy/deprecated `executionFailed` response field, which is not a supported public signal).
- **Check `doNotPropagateError`:** When `ExecuteIntegrationsRequest.doNotPropagateError` is `true`, a failing execution does not return an HTTP error. Instead, it returns HTTP 200 with an `executionId` and places error messages inside the event parameters.
- **Check `ErrorInfo` in `responseParameters`:** On failure, `Execution.responseParameters` includes:
  ```json
  {
    "ErrorInfo": {
      "message": "Error description",
      "code": 403
    }
  }
  ```
- **Check `requestId` deduplication:** If `ExecuteIntegrationsRequest.requestId` matches a previous request, Application Integration returns the previous execution's response without running the tasks again.
- **Check task failure policies (`FailurePolicy.retryStrategy`):**
  - `IGNORE` ignores the task failure and runs the rest of the integration as if the task succeeded.
  - `NONE` (also applied when no `FailurePolicy` is set) stops dependent tasks on that branch, but an alternate branch can still finish and mark the overall execution `SUCCEEDED`.

## Execution-Level States (`ExecutionDetails.state`)

`Execution.executionDetails.state` tracks the overall run. It also holds `attemptStats` (start and end time of each attempt), `executionSnapshots`, and `eventExecutionSnapshotsSize`.

| API `ExecutionDetails.state` | Console Execution Logs status | Terminal? | Meaning |
|---|---|---|---|
| `STATE_UNSPECIFIED` | - | No | Default unspecified enum value. |
| `PENDING` | On hold | No | Scheduled or temporarily paused and waiting to be triggered. |
| `PROCESSING` | In process | No | Currently running. |
| `SUCCEEDED` | Succeeded | Yes | Completed without an unhandled fatal error. Verify per-task states if expected side effects are missing. |
| `FAILED` | Failed | Yes | Ended with an unhandled failure. Check `ErrorInfo` and per-task states. |
| `CANCELLED` | Canceled | Yes | Canceled by a user, canceled when a new version was published over a suspended run, or timed out (for example, SYNC > 2 min or replay > 10 min). |
| `RETRY_ON_HOLD` | Retry on hold | No | Failed with a temporary error and waiting in the backoff retry queue. |
| `SUSPENDED` | Suspended | No | Waiting for resolution of an Approval task (in the Cloud console UI or via `suspensions:resolve`) or a Suspend task (via `suspensions:lift`). |

## Execution Methods (`Execution.executionMethod`)

| `Execution.executionMethod` | Execution mode | Description |
|---|---|---|
| `EXECUTION_METHOD_UNSPECIFIED` | - | Default value. |
| `POST` | Synchronous (`SYNC`) | Sync post. |
| `POST_TO_QUEUE` | Asynchronous (`ASYNC`) | Async post. |
| `SCHEDULE` | Asynchronous (`ASYNC`) | Async post with schedule time. |

Synchronous runs include console test/publish, `projects.locations.integrations.execute`, and synchronous Call Integration sub-workflows. Asynchronous runs include Schedule, Cloud Scheduler, Cloud Pub/Sub, and Salesforce triggers, `projects.locations.integrations.schedule`, and executions resumed after a suspension or approval.

## Task-Level States (`TaskExecutionDetails.taskExecutionState`)

Inspect `taskExecutionState` inside each execution snapshot to see exactly which task failed or was skipped.

| `taskExecutionState` | Meaning |
|---|---|
| `TASK_EXECUTION_STATE_UNSPECIFIED` | Default value. |
| `PENDING_EXECUTION` | Task has not started yet. |
| `IN_PROCESS` | Task is currently executing. |
| `SUCCEED` | Task completed successfully. |
| `FAILED` | Task failed. Check its `FailurePolicy` (`IGNORE`, `NONE`, or backoff retry) to see how the workflow handled it. |
| `FATAL` | Task failed with strategy `FATAL`, causing the entire integration execution to fail immediately. |
| `RETRY_ON_HOLD` | Task failed and is waiting for its next retry attempt. |
| `SKIPPED` | Task edge precondition was not met, or the execution was canceled before reaching this task. |
| `CANCELLED` | Task execution was canceled. |
| `PENDING_ROLLBACK` | Task is queued for rollback. |
| `ROLLBACK_IN_PROCESS` | Task rollback is currently running. |
| `ROLLEDBACK` | Task rollback finished. |
| `SUSPENDED` | A SuspensionTask (Suspend or Approval) ran once and created a pending suspension. |

## Listing and Filtering Executions (`executions.list`)

`GET https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions` returns the same execution records shown in the Cloud console Execution Logs page. Pass `-` for `INTEGRATION_NAME` to query across all integrations in `LOCATION`.

### Supported `filter` Fields and Operators

| Filter field | Supported operators | Example |
|---|---|---|
| `state` | `=`, `!=` | `state=FAILED` or `state!=SUCCEEDED` (unquoted `ExecutionDetails.state` value: `PENDING`, `PROCESSING`, `SUCCEEDED`, `FAILED`, `CANCELLED`, `RETRY_ON_HOLD`, `SUSPENDED`; for example, `filter=state=FAILED`, `filter=state=CANCELLED`, or `filter=state=FAILED OR state=CANCELLED`, URL-encoded as needed) |
| `workflow_name` | `=` | `workflow_name="INTEGRATION_NAME"` |
| `execution_id` | `=` | `execution_id="EXECUTION_ID"` |
| `trigger_id` | `=` | `trigger_id="api_trigger/TRIGGER_NAME"` |
| `update_time` | Supported filter key (operators are documented only for `CreateTimestamp`: `=`, `<`, `>`; `state`: `=`, `!=`) | - |
| `CreateTimestamp` | `=`, `<`, `>` | `CreateTimestamp>"TIMESTAMP"` (illustrative; value format is not specified in the discovery doc) |
| `parameter_type` | `=`, `HAS` | `"parameter_type" HAS "string"` |

Combine clauses with `AND`, `OR`, and `NOT` (for example, `state=FAILED OR state=CANCELLED`, or `trigger_id="api_trigger/TRIGGER_NAME" AND workflow_name="INTEGRATION_NAME"`). Use the supported filter keys (`execution_id`, `state`, `update_time`, `workflow_name`, `trigger_id`, `CreateTimestamp`, `parameter_type`); camelCase variants such as `executionId` are not supported even though some docs examples show them. Use `state`, not `eventExecutionState` (as shown on the REST reference page) or `event_execution_state` (in the API reference's filter description).

### Useful Query Parameters

- `filter`: filters executions using the fields above (such as `state=FAILED` or `execution_id="EXECUTION_ID"`, URL-encoded as needed).
- `snapshotMetadataWithoutParams=true`: returns lightweight execution metadata and IDs without large parameter payloads.
- `readMask`: limits returned fields (for example, `execution_details.state,cloud_logging_details,replay_info`).
- `orderBy=create_time`: orders runs by creation time (sort direction is not specified in the discovery doc; paginate with `pageToken` or add a `CreateTimestamp` filter if needed).
- `pageSize` and `pageToken`: paginates through results.
- **Deprecated query parameters to avoid:** Do **not** use `truncateParams` (deprecated, `"Only works for UI"`) or `filterParams.*` (deprecated, internal-only). Use `filter`, `snapshotMetadataWithoutParams=true`, and `readMask` instead.

### Handling "Response size too large" (> 300 MB)

If an execution's logs exceed 300 MB, the Cloud console shows `Response size too large`. Bypass this by calling `executions.list` with `snapshotMetadataWithoutParams=true` or a narrow `readMask`, then inspect specific task variables or Cloud Logging entries.

### Example: Two-Step Execution Lookup

```bash
# Step 1: List recent failed executions without parameter payloads
curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions?filter=state%3DFAILED&snapshotMetadataWithoutParams=true&pageSize=20"

# Step 2: Fetch full details for one EXECUTION_ID across any integration in LOCATION
curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/-/executions?filter=execution_id%3D%22EXECUTION_ID%22"
```

## AI Troubleshooting (`v2` `executions:troubleshoot`)

The v2 REST API provides an LLM-powered root-cause explanation for a failed execution. It requires `integrations.executions.get` (included in `roles/integrations.integrationViewer`, `integrationInvoker`, `integrationEditor`, and `integrationAdmin`).

```bash
curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://integrations.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions/EXECUTION_ID:troubleshoot"
```

- **Response fields:** `executionId`, `displayMessage`, `errorMessage`, `rootCause`, and `detailedExplanation`.
- **Console requirements:** In the Cloud console, Gemini AI troubleshooting works only on failed executions of published (`ACTIVE`) integrations, and AI features must be enabled for the region.
- **Other v2 read endpoints:** `v2` also exposes `executions.list` and `executions.taskExecutions.get`.

## Canceling and Replaying Executions

Both `:cancel` and `:replay` change runtime state. Show the exact command and obtain user confirmation before executing either call.

### Cancel (`executions:cancel`)

- **IAM required:** `integrations.executions.cancel` (included in `roles/integrations.integrationInvoker`, `roles/integrations.integrationEditor`, and `roles/integrations.integrationAdmin`—**not** in `roles/integrations.suspensionResolver` or `roles/integrations.integrationViewer`, so approvers with only `roles/integrations.suspensionResolver` cannot cancel a stuck `SUSPENDED` run).
- **Allowed states:** Only executions in `PENDING` (console "On hold"), `RETRY_ON_HOLD` (console "Retry on hold"), or `SUSPENDED` (console "Suspended") can be canceled.
- **Disallowed cases:** Cannot cancel an execution in the `PROCESSING` state (console "In process"), a completed execution (`SUCCEEDED`, `FAILED`, `CANCELLED`), or any execution started by a Schedule trigger.
- **Behavior:** Cancels the execution and its sub-executions. Requires `cancelReason` in the request body.

```bash
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{"cancelReason": "User requested cancel of stuck retry"}' \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions/EXECUTION_ID:cancel"
```

### Replay (`executions:replay` - Preview)

- **Availability:** Preview feature; works only on published (`ACTIVE`) integrations.
- **IAM required:** `integrations.executions.replay` (included in `roles/integrations.integrationInvoker`, `roles/integrations.integrationEditor`, and `roles/integrations.integrationAdmin`—**not** in `roles/integrations.suspensionResolver` or `roles/integrations.integrationViewer`).
- **Allowed states:** Only `SUCCEEDED`, `FAILED`, or `CANCELLED` (console "Succeeded", "Failed", or "Canceled") executions can be replayed. If an execution is paused or retrying, cancel it first before replaying.
- **Disallowed cases and preconditions (`FAILED_PRECONDITION`):**
  - Executions started by a Schedule trigger cannot be replayed.
  - **Test-case runs** cannot be replayed in any mode (returns `FAILED_PRECONDITION`: `"Test runs cannot be replayed."`).
  - **`REPLAY_MODE_POINT_OF_FAILURE` when database persistence is disabled:** Refused with `FAILED_PRECONDITION` for executions that ran with database persistence (local logging / `databasePersistencePolicy: DATABASE_PERSISTENCE_DISABLED`) disabled, because point-of-failure replay requires execution snapshots; use `REPLAY_MODE_FROM_BEGINNING` in that case.
- **Deadline and mode:** Replayed runs keep the original execution mode (`SYNC` or `ASYNC`) and have a 10-minute default deadline, after which their state becomes `CANCELLED`.
- **Replay modes (`replayMode`):**
  - `REPLAY_MODE_FROM_BEGINNING`: re-runs the entire execution from the trigger.
  - `REPLAY_MODE_POINT_OF_FAILURE`: re-runs starting from the failed task (available only for failed executions that ran with database persistence enabled; if the version used `databasePersistencePolicy: DATABASE_PERSISTENCE_DISABLED`, `REPLAY_MODE_POINT_OF_FAILURE` is refused with `FAILED_PRECONDITION` because it needs execution snapshots—use `REPLAY_MODE_FROM_BEGINNING` in that case).
- **Optional parameter override (`modifiedParameters` and `updateMask`):** Pass `modifiedParameters` and `updateMask` to override inputs on replay. List every overridden key in `updateMask`; without `updateMask`, all original inputs are discarded and only `modifiedParameters` are used, and a key in `updateMask` missing from `modifiedParameters` is an error.
- **Response fields:** `executionId`, `replayedExecutionId`, and `outputParameters`.

```bash
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{
    "replayReason": "Replaying from failed task after fixing target service access",
    "replayMode": "REPLAY_MODE_POINT_OF_FAILURE"
  }' \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions/EXECUTION_ID:replay"
```
logging-and-monitoring.md 9.9 KB
# Cloud Logging and Cloud Monitoring

Use this reference to check why execution logs are missing, enable Cloud Logging on an integration or connector, run Logs Explorer and `gcloud logging read` queries, and inspect Cloud Monitoring metrics and alerts.

- [Local Logging vs Cloud Logging](#local-logging-vs-cloud-logging): Lines 11-28
- [Enabling Cloud Logging on an Integration](#enabling-cloud-logging-on-an-integration): Lines 29-45
- [Cloud Logging Queries (`gcloud logging read` and Logs Explorer)](#cloud-logging-queries-gcloud-logging-read-and-logs-explorer): Lines 46-110
- [Cloud Monitoring Metrics](#cloud-monitoring-metrics): Lines 111-138
- [Dashboards and Alerting](#dashboards-and-alerting): Lines 139-147

## Local Logging vs Cloud Logging

Application Integration has two logging layers. Cloud Logging depends on local logging being active.

| Setting (`databasePersistencePolicy`) | Console default | Behavior and caveats |
|---|---|---|
| **Local logging: `Enable (async)`** (`DATABASE_PERSISTENCE_ASYNC`) | Yes | Writes execution logs asynchronously with minimal latency overhead (the Cloud console default). Can, rarely, miss logs. |
| **Local logging: `Enable (sync)`** (`DATABASE_PERSISTENCE_POLICY_UNSPECIFIED`) | No (API default) | The API default—a version built over REST without `databasePersistencePolicy` persists synchronously. Guarantees execution logs are written before continuing, but adds execution latency. |
| **Local logging: `Disable`** (`DATABASE_PERSISTENCE_DISABLED`) | No | Generates no execution logs (and `REPLAY_MODE_POINT_OF_FAILURE` is refused because no execution snapshots are stored). **Nothing is sent to Cloud Logging even if Cloud Logging is enabled.** |
| **Cloud Logging** (`cloudLoggingDetails.enableCloudLogging`) | No (disabled by default) | Exports execution logs to the project's `_Default` bucket under `integrations.googleapis.com/IntegrationVersion`. |

### Critical Size and Truncation Rules

- **10 MB local-logging cutoff:** Total integration data (inputs, outputs, and variables) can be up to 30 MB, but **above 10 MB, local logging is automatically disabled**. The integration still runs, but you cannot view full logs, apply a task retry strategy, or see the run in the monitoring dashboard.
- **256 KiB Cloud Logging limit:** Each Cloud Logging entry is limited to 256 KiB. Above 256 KiB, request and response parameters are omitted from the log entry.
- **2,000-character message truncation:** Event parameters inside log messages are truncated at 2,000 characters. Use the Cloud console **Task Execution Details** pane (or download the execution log as JSON) to view untruncated task variables and request/response parameters.
- **Latency note:** Do not use the Execution Logs `Duration` column as end-to-end client latency; it excludes time spent on authentication and quota enforcement.

## Enabling Cloud Logging on an Integration

Cloud Logging is configured per integration version (`IntegrationVersion.cloudLoggingDetails`), while local logging corresponds to `IntegrationVersion.databasePersistencePolicy`: `DATABASE_PERSISTENCE_POLICY_UNSPECIFIED` = `Enable (sync)` (the API default—a version built over REST without `databasePersistencePolicy` persists synchronously), `DATABASE_PERSISTENCE_ASYNC` = `Enable (async)` (the console default), and `DATABASE_PERSISTENCE_DISABLED` = `Disable`.

1. Open the integration in `https://console.cloud.google.com/integrations` and switch to a **DRAFT** version (click **Enable Editing** if it is published).
2. Open **Integration summary / settings > Log settings**.
3. Enable **Cloud Logging**, choose a **Severity**, click **Save**, and **Publish** the version.

| Severity (`cloudLoggingSeverity`) | Execution states captured in Cloud Logging (`jsonPayload.integrationExecutionDetails.integrationExecutionState`) |
|---|---|
| `INFO` | All states: `SUCCEEDED`, `FAILED`, `IN_PROCESS`, `ON_HOLD`, `SUSPENDED`, `RETRY_ON_HOLD`, `CANCELLED` |
| `WARNING` | `FAILED` and `CANCELLED` only |
| `ERROR` | `FAILED` and `CANCELLED` only |

The Cloud Logging payload enum (`jsonPayload.integrationExecutionDetails.integrationExecutionState`) uses `ON_HOLD` and `IN_PROCESS` where the API and filter enum (`ExecutionDetails.state`) uses `PENDING` and `PROCESSING`; `FAILED`, `SUCCEEDED`, `CANCELLED`, `RETRY_ON_HOLD`, and `SUSPENDED` are the same as in the API.
Check whether Cloud Logging was enabled on a past run by reading `Execution.cloudLoggingDetails` via `executions.list`.

## Cloud Logging Queries (`gcloud logging read` and Logs Explorer)

All Application Integration execution logs use `resource.type="integrations.googleapis.com/IntegrationVersion"`. Audit logs are viewable only in Cloud Logging. Logs live in `_Default` by default and can be routed to other buckets, BigQuery, or Pub/Sub.

### Common Query Patterns

```text
# 1. All Application Integration logs in the project
resource.type="integrations.googleapis.com/IntegrationVersion"

# 2. One parent execution only (excludes child sub-executions)
resource.type="integrations.googleapis.com/IntegrationVersion"
jsonPayload.executionId="EXECUTION_ID"

# 3. Parent execution AND all child sub-executions (free-text match on EXECUTION_ID)
resource.type="integrations.googleapis.com/IntegrationVersion"
"EXECUTION_ID"

# 4. All runs for one integration
resource.type="integrations.googleapis.com/IntegrationVersion"
jsonPayload.integration="INTEGRATION_NAME"

# 5. Failed executions for one integration
resource.type="integrations.googleapis.com/IntegrationVersion"
jsonPayload.integration="INTEGRATION_NAME"
jsonPayload.integrationExecutionDetails.integrationExecutionState="FAILED"

# 6. Search by request parameter name (for example requestUrl)
resource.type="integrations.googleapis.com/IntegrationVersion"
"requestUrl"
```

### Running Queries with `gcloud logging read`

```bash
# Read failed execution logs for INTEGRATION_NAME
gcloud logging read \
  'resource.type="integrations.googleapis.com/IntegrationVersion" AND jsonPayload.integration="INTEGRATION_NAME" AND jsonPayload.integrationExecutionDetails.integrationExecutionState="FAILED"' \
  --project="PROJECT_ID" \
  --limit=25 \
  --format=json
```

### Tracing a Failed Integration Connectors Task

Connector logs are **disabled by default** on each connection. When enabled on the connection (levels: `Error`, `Info`, or `Debug`), every Connectors task attempt logs with a trace ID joining the integration execution ID, task ID, and attempt number.

```bash
# Query all logs for a specific connection in LOCATION
gcloud logging read \
  'resource.type="connectors.googleapis.com/Connection" AND resource.labels.location="LOCATION" AND resource.labels.connection="CONNECTION_NAME"' \
  --project="PROJECT_ID" \
  --limit=25 \
  --format=json

# Trace one exact Connectors task attempt (format: EXECUTIONID_TASKID_ATTEMPTNUMBER)
gcloud logging read \
  'resource.type="connectors.googleapis.com/Connection" AND jsonPayload.integration_connectors_trace_id="EXECUTIONID_TASKID_ATTEMPTNUMBER"' \
  --project="PROJECT_ID" \
  --limit=20 \
  --format=json
```

In the Cloud console Execution Logs table, clicking **Failed** in the Status column of a Connectors task opens Logs Explorer pre-populated with `jsonPayload.integration_connectors_trace_id`.

## Cloud Monitoring Metrics

Application Integration metrics are GA, sampled every 60 seconds (up to 86,400 seconds visibility delay), and emitted **only for published integrations**. Skipped tasks do not emit step counts. Metric values are informational and must not be used to calculate billing.

### Monitored Resource: `integrations.googleapis.com/IntegrationVersion`

- **Resource labels:** `resource_container` (project ID), `location`, `integration`, `version`.

| Metric (`integrations.googleapis.com/...`) | Kind / Type | Metric labels | What it measures |
|---|---|---|---|
| `integration/execution_count` | DELTA / INT64 | `status` (`SUCCEEDED`, `FAILED`, `CANCELLED`, `RETRY_ON_HOLD`), `trigger_name`, `trigger_id`, `error_enum` (for example `PERMISSION_DENIED`), `is_retry` | Total integration executions. |
| `integration/execution_latencies` | DELTA / DISTRIBUTION (ms) | `status`, `trigger_name`, `trigger_id`, `error_enum`, `is_retry` | Integration execution duration distribution. |
| `processed_bytes_count` | DELTA / INT64 (By) | `step_type`, `step_name`, `step_id` | Input/output parameter size plus Call REST Endpoint and Connectors task payload size. |
| `step/execution_count` | DELTA / INT64 | `status`, `step_type`, `step_name`, `step_id`, `error_enum`, `is_retry`, `is_step_external` | Task and trigger execution count (excludes skipped tasks). |
| `step/execution_latencies` | DELTA / DISTRIBUTION (ms) | `status`, `step_name`, `step_id`, `error_enum`, `is_retry`, `is_step_external` | Task and trigger execution duration distribution (no `step_type` label). |

### Integration Connectors Metrics (`connectors.googleapis.com/...` - Beta)

Monitored resource: `connectors.googleapis.com/Connection`.
- `connection/connection_status` (GAUGE / BOOL, label `status`)
- `connection/state`
- `connection/nodes`
- `connection/request_count`
- `connection/response_count` (labels: `code`, `service`, `method`, `connector_fault`)
- `connection/latencies`
- `connection/request_sizes` and `connection/response_sizes`
- `connection/event_count` and `connection/event_request_sizes`

## Dashboards and Alerting

- **Sample dashboards:** In Cloud Monitoring, open **Dashboards > Sample library > Application Integration** to install prebuilt views for:
  - Integration executions
  - Step executions
  - Integration and task execution duration
  - Data processed
- **Metric alerts:** Requires `roles/monitoring.editor`. Create an alert policy on resource **Integration Version** (`integrations.googleapis.com/IntegrationVersion`) filtered by `status="FAILED"` or `error_enum`.
- **Log-based alerts:** Create a Cloud Logging alert matching `resource.type="integrations.googleapis.com/IntegrationVersion"` and `jsonPayload.integrationExecutionDetails.integrationExecutionState="FAILED"`.
suspensions.md 10.6 KB
# Suspensions, Approval Tasks, and Timer Tasks

Use this reference when an execution is paused in `SUSPENDED` state, when an Approval email link fails to resume a run, or when you need to list suspensions, lift a Suspend task, or resolve (approve/reject) an Approval task via the REST API.

- [Comparison: Suspend vs Approval vs Timer Tasks](#comparison-suspend-vs-approval-vs-timer-tasks): Lines 12-19
- [Lifecycle Rules and Gotchas](#lifecycle-rules-and-gotchas): Lines 20-26
- [IAM Required to View, Approve, or Lift Suspensions](#iam-required-to-view-approve-or-lift-suspensions): Lines 27-38
- [Listing Suspensions (`suspensions.list`)](#listing-suspensions-suspensionslist): Lines 39-59
- [Resolving an Approval Task or Lifting a Suspend Task (Requires User Confirmation)](#resolving-an-approval-task-or-lifting-a-suspend-task-requires-user-confirmation): Lines 60-104
- [Troubleshooting Stuck Approval Tasks](#troubleshooting-stuck-approval-tasks): Lines 105-113

## Comparison: Suspend vs Approval vs Timer Tasks

| Task | How it resumes | Resumable via REST API? | Max / default duration | Output / branching |
|---|---|---|---|---|
| **Suspend** | Manual via Suspensions API (`suspensions:lift`), or automatically on timeout expiry. | **Yes** (`suspensions:lift`, which accepts an optional `suspensionResult`) | Max and default: 44,640 minutes (31 days). | Sets suspension result (`Resolved` if lifted with no value, `Expired` on timeout, or custom `suspensionResult`). |
| **Approval** | Approve/Reject in the Cloud console UI or via the REST API (`suspensions:resolve` with `state` `"LIFTED"` or `"REJECTED"`—the same call the console buttons make). | **Yes** (`suspensions:resolve`; always confirm with user first) | Configurable `Time until expiration` (hours) and `Reminder frequency` (hours). | Outputs boolean `` `Task_<taskId>_isApproved` `` where `taskId` is the bare task number in `taskConfigs[].taskId` (for example, `taskId` `"2"` -> `` $`Task_2_isApproved`$ = TRUE ``). |
| **Timer** | Automatically when the timer elapses. | **No** (automatic only) | Default 120 seconds; max 44,640 minutes (31 days). | < 60 s behaves like synchronous mode; >= 60 s runs in asynchronous mode. |

## Lifecycle Rules and Gotchas

- **Cannot test before publishing:** Integrations that contain an Approval, Suspend, or Timer task cannot be tested in draft state. Publish the version first (for example, to a non-production project and invoke `integrations:execute`).
- **Publishing a new version cancels suspended runs:** Publishing a new version of an integration **automatically cancels** all suspended executions of the previously published version.
- **31-day maximum lifetime:** An integration execution can last at most **31 days total**, including all time paused in Approval or Suspend tasks.
- **Resumed runs are always asynchronous:** When an execution resumes from a suspension or approval, the remainder of the run always executes in **asynchronous (`ASYNC`)** mode, even if the original trigger was synchronous (`:execute`).

## IAM Required to View, Approve, or Lift Suspensions

Many stuck approvals happen because the recipient can open the integration but lacks suspension or run-as service account permissions.

1. **Suspension permissions (`integrations.suspensions.list`, `integrations.suspensions.resolve`, `integrations.suspensions.lift`):**
   - `:resolve` (Approval task) requires `integrations.suspensions.resolve`; `:lift` (Suspend task) requires `integrations.suspensions.lift`; `suspensions.list` requires `integrations.suspensions.list`. All three permissions are included in `roles/integrations.suspensionResolver` (Application Integration Approver) and `roles/integrations.integrationAdmin`.
   - **Gotcha:** `roles/integrations.integrationEditor` does **not** include `integrations.suspensions.list`, `integrations.suspensions.resolve`, or `integrations.suspensions.lift`. Conversely, `roles/integrations.suspensionResolver` contains only `integrations.suspensions.list`, `integrations.suspensions.resolve`, and `integrations.suspensions.lift` (plus `resourcemanager.projects.get` and `resourcemanager.projects.list`): it does **not** include `integrations.executions.cancel` (held by `roles/integrations.integrationInvoker`, `roles/integrations.integrationEditor`, and `roles/integrations.integrationAdmin`), so approvers with only `roles/integrations.suspensionResolver` cannot cancel a stuck `SUSPENDED` run via `executions:cancel`. In addition, `roles/integrations.suspensionResolver` alone cannot read execution records (no `integrations.executions.list` or `integrations.executions.get`, returning HTTP 403 on `executions.list` and v2 `:troubleshoot`); to inspect `taskExecutionDetails` (or run `:troubleshoot`), also grant `roles/integrations.integrationViewer` (or use the approval email link, which carries the execution and task IDs).
   - **Visibility rule:** Calling `suspensions.list` requires `integrations.suspensions.list`, and only callers who hold permission to resolve the relevant suspensions can view them.
2. **Run-as service account permission (`roles/iam.serviceAccountUser`):**
   - If the integration version has a `runAsServiceAccount` configured, the approver or resolver must also hold `roles/iam.serviceAccountUser` on that service account (in the project that owns the service account).
   - **Gotcha:** Without `roles/iam.serviceAccountUser`, clicking approve or attempting to resume fails to advance the workflow, and the execution **stays paused until it expires**.

## Listing Suspensions (`suspensions.list`)

Use `suspensions.list` (read-only; requires `integrations.suspensions.list`, included in `roles/integrations.suspensionResolver`) to inspect pending suspensions for an execution.

```bash
curl -sS -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions/EXECUTION_ID/suspensions"
```

### Suspension States and Expiration Fields

- `Suspension.state`:
  - `RESOLUTION_STATE_UNSPECIFIED`: unset state.
  - `PENDING`: waiting for resolution or expiration.
  - `LIFTED`: approved / lifted; execution resumes.
  - `REJECTED`: rejected (either manually or by default upon expiration).
- `SuspensionApprovalExpiration`:
  - `expireTime`: timestamp when the suspension expires.
  - `remindTime`: timestamp for the next reminder email.
  - `liftWhenExpired`: boolean controlling expiration behavior. For Approval tasks, **reject (`REJECTED`) is the default** on expiration unless configured to lift.

## Resolving an Approval Task or Lifting a Suspend Task (Requires User Confirmation)

Both **Approval** tasks (`suspensions:resolve`) and **Suspend** tasks (`suspensions:lift`) can be resumed via the public REST API. Always show the exact command and obtain user confirmation before calling `:resolve` or `:lift`.

### Approve or Reject an Approval Task (`suspensions:resolve`)

`suspensions:resolve` approves (`"state": "LIFTED"`) or rejects (`"state": "REJECTED"`) an **Approval** task by passing the `Suspension` record (`eventExecutionInfoId`, `integration`, `taskId`, and target `state`). This is the same call the Cloud console Approve/Reject buttons make. The caller needs `integrations.suspensions.resolve` (such as `roles/integrations.suspensionResolver`) plus `roles/iam.serviceAccountUser` on the integration's run-as service account.

```bash
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{
    "suspension": {
      "eventExecutionInfoId": "EXECUTION_ID",
      "integration": "INTEGRATION_NAME",
      "taskId": "TASK_ID",
      "state": "LIFTED"
    }
  }' \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions/EXECUTION_ID/suspensions/SUSPENSION_ID:resolve"
```

### Lift a Suspend Task (`suspensions:lift`)

`suspensions:lift` is the **Suspend**-task variant (requires `integrations.suspensions.lift`, included in `roles/integrations.suspensionResolver`, plus `roles/iam.serviceAccountUser` on the integration's run-as service account). `LiftSuspensionRequest` takes an optional `suspensionResult` (string), which you can match in downstream edge conditions. If you omit `suspensionResult`, Application Integration sets the result to `Resolved`.

- **Wildcard `-` rules:** You may pass `-` for `INTEGRATION_NAME`. You may also pass `-` for either `EXECUTION_ID` or `SUSPENSION_ID`, provided at least **one** of `EXECUTION_ID` or `SUSPENSION_ID` is a real ID.

```bash
# Lift by EXECUTION_ID and SUSPENSION_ID with a custom suspensionResult
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{"suspensionResult": "Approved"}' \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/INTEGRATION_NAME/executions/EXECUTION_ID/suspensions/SUSPENSION_ID:lift"

# Lift using EXECUTION_ID and wildcard '-' for INTEGRATION_NAME and SUSPENSION_ID
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{"suspensionResult": "Approved"}' \
  "https://integrations.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/integrations/-/executions/EXECUTION_ID/suspensions/-:lift"
```

## Troubleshooting Stuck Approval Tasks

If an Approval task is stuck in `SUSPENDED` or failed after approval:

1. **Use the matching endpoint for the task type:** Approval tasks use `suspensions:resolve` (with `state` set to `"LIFTED"` or `"REJECTED"`, the same call the Cloud console Approve/Reject buttons make; confirm with the user first), whereas `suspensions:lift` (which takes an optional `suspensionResult`) is the Suspend-task variant.
2. **Check approver IAM:** Verify the recipient has `integrations.suspensions.resolve` (`roles/integrations.suspensionResolver` or `roles/integrations.integrationAdmin`) on the project (or `integrations.suspensions.lift` when lifting a Suspend task), **plus** `roles/iam.serviceAccountUser` on `IntegrationVersion.runAsServiceAccount`.
3. **Check whether a new version was published:** Run `versions.list` on the integration. If a new version was published after the execution started, the suspended execution was automatically canceled (`CANCELLED`).
4. **Check expiration (`expireTime`):** If the approval window elapsed, check whether `On expiration` was set to **Reject** (default, setting `` `Task_<taskId>_isApproved` ``, such as `` $`Task_2_isApproved`$ `` for `taskId` `"2"`, to `FALSE`) or **Lift**.
5. **Check the 31-day cap:** If the execution has been paused for 31 days total, it hits the maximum execution lifetime limit.

License (Apache-2.0)

View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/google/skills/blob/main/LICENSE