Skip to content

fix(drive-integration): show actionable error when app not installed in environment []#11012

Open
Mitch Goudy (mgoudy91) wants to merge 4 commits into
masterfrom
fix/app-not-installed-error-handling
Open

fix(drive-integration): show actionable error when app not installed in environment []#11012
Mitch Goudy (mgoudy91) wants to merge 4 commits into
masterfrom
fix/app-not-installed-error-handling

Conversation

@mgoudy91

@mgoudy91 Mitch Goudy (mgoudy91) commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Problem

When a Google Drive import fails due to the app not being installed in a space, users see a generic "This preview could not be completed. Please start again." message with no actionable guidance.

Fix

Adds frontend handling for two new failure codes surfaced by agents-api:

  • app-not-installed — shown when the app is not installed in the space (after the master env fallback in agents-api also finds nothing). Message: "The Drive Integration app is not installed in this space. Install it via Apps > Manage apps and try again."
  • ai-service-unavailable — shown when the AI service is temporarily unavailable. Message: "The AI service is temporarily unavailable. Please try again in a few minutes."

Both codes are handled in useWorkflowAgent, WorkflowFailureReason, and ModalOrchestrator.

Test plan

  • Verify APP_NOT_INSTALLED error modal appears with correct title and message
  • Verify AI_SERVICE_UNAVAILABLE error modal appears with correct title and message
  • Verify generic error still shows for unrecognized failure codes

Related: contentful/agents-api#615

🤖 Generated with Claude Code

…in environment

When the Drive Integration app is not installed in a non-master environment,
the workflow run was completing as COMPLETED with no payload, causing the
frontend to show the generic "This preview could not be completed" message.

Adds APP_NOT_INSTALLED as a mapped WorkflowFailureReason so users see:
"The Drive Integration app is not installed in this environment. Install it
via Apps > Manage apps and try again."

Also adds AI_SERVICE_UNAVAILABLE handling which was missing from the
frontend failure mapping.

Requires agents-api counterpart: contentful/agents-api#<see PR>

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mgoudy91 Mitch Goudy (mgoudy91) requested review from a team as code owners June 4, 2026 18:49
… space not environment

With the master environment fallback in agents-api, this error only fires when
the app truly isn't installed in the space, so the message should direct users
to install at the space level rather than implying a per-environment install.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mgoudy91 Mitch Goudy (mgoudy91) changed the title fix(drive-integration): show actionable error when app not installed in environment fix(drive-integration): show actionable error when app not installed in environment [] Jun 4, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lewisjcs

Copy link
Copy Markdown
Contributor

⚔️ The Gauntlet — 🛡️ 0 Blockers · 3 advisory

🤖 AI-powered · your code, through the lanes

gauntlet verdict

🛑 Blockers 0
⚠️ Concerns 2
💡 Nits 1
🔒 Security clean ✓
🧪 Lanes code-quality · adversarial · security

Findings

Finding Location Status
⚠️ APP_NOT_INSTALLED copy tells users to reinstall an installed app when ext-api returns a transient 502. agents-api#615 maps 404 || 502 to the same app-not-installed code, but 502 is BadGatewayError (infra), not "not installed". Frontend lever: soften the copy so it covers the transient case. Root fix: stop mapping 502 → app-not-installed in #615. messages.ts:15 Open
⚠️ Modal title says "environment", body says "space" for the same error — two different scoping words in one modal. Root cause is environment-scoped (the master-alias fallback), so "environment" is the more accurate term. Pick one and use it in both. ModalOrchestrator.tsx:196messages.ts:15 Open
💡 No unit test for the new code → reason → message mapping. It's a cross-service string contract; a typo silently falls through to GENERIC. Add a test asserting 'app-not-installed' / 'ai-service-unavailable' map to the right reason + message. useWorkflowAgent.ts:130 Open

One thing worth confirming: is there a throw site for PREVIEW_AGENT_FAILED (which #615 maps to ai-service-unavailable)? It wasn't found in #615's diff, so the ai-service-unavailable half of this PR may be inert until a later producer change lands. Not a blocker — just worth a sanity check.

🤖 Machine-readable findings (for agents)
{
  "tool": "gauntlet",
  "schema": "v1",
  "reviewed_ref": "3b21947",
  "verdict": { "blockers": 0, "concerns": 2, "nits": 1, "security": "clean" },
  "findings": [
    { "severity": "concern", "location": "apps/drive-integration/src/utils/constants/messages.ts:15", "lens": "adversarial-review / Failure Scenarios", "confidence": 90, "claim": "APP_NOT_INSTALLED copy is shown on a transient ext-api 502 (agents-api#615 maps 404||502 to app-not-installed), telling users to reinstall an installed app.", "recommendation": "Soften the frontend copy to cover the transient case; fix the root cause in agents-api#615 by not mapping 502 to app-not-installed." },
    { "severity": "concern", "location": "apps/drive-integration/src/locations/Page/components/mainpage/ModalOrchestrator.tsx:196", "lens": "adversarial-review / Hidden Assumptions", "confidence": 92, "claim": "Modal title says 'environment' while body copy says 'space' for the same APP_NOT_INSTALLED error.", "recommendation": "Use one consistent term in title and body; 'environment' matches the root cause." },
    { "severity": "nit", "location": "apps/drive-integration/src/hooks/useWorkflowAgent.ts:130", "lens": "code-quality-standards / Gaps", "confidence": 80, "claim": "No unit test covers the new code->reason->message mapping across the cross-service string contract.", "recommendation": "Add a unit test asserting app-not-installed and ai-service-unavailable map to the correct reason and message." }
  ]
}

🎮 The Gauntlet · an AI review harness built by Josh C.S. Lewis · reviewed at 3b21947. Everything but the 🛑 is advisory.

…OT_INSTALLED error []

Modal title and body now both say "environment" to match the actual root cause
(env-scoped app installation).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
JuliRossi added a commit that referenced this pull request Jun 11, 2026
…ABLE error handling

Ports error cases from #11012 — surfaces actionable messages when the
app is not installed in the target environment or the AI service is down.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
JuliRossi added a commit that referenced this pull request Jun 11, 2026
…ABLE error handling

Ports error cases from #11012 — surfaces actionable messages when the
app is not installed in the target environment or the AI service is down.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
JuliRossi added a commit that referenced this pull request Jun 12, 2026
…s [INTEG-4151] (#11020)

* fix(drive-integration): use environment alias for agents API calls

sdk.ids.environment returns the real environment ID (e.g. master-2026-06-09)
instead of the alias (master), causing the agents API path to not match
aliased environments. Fall back to raw ID when no alias is set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(drive-integration): resolve environment alias before agents API calls

When the app is opened on a raw environment ID (e.g. master-2026-06-09),
sdk.ids.environmentAlias is undefined. Fall back to fetching the environment
and reading sys.aliases to find the alias name, so the agents API path
matches the app installation which is scoped to the alias.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(drive-integration): add unit tests for resolveEnvironmentId

Covers: alias fast-path, CMA alias lookup, no-alias fallback,
and CMA error fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(drive-integration): add APP_NOT_INSTALLED and AI_SERVICE_UNAVAILABLE error handling

Ports error cases from #11012 — surfaces actionable messages when the
app is not installed in the target environment or the AI service is down.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(drive-integration): simplify env alias resolution to sdk.ids.environmentAlias ?? sdk.ids.environment

Replaces the resolveEnvironmentId helper (which made a CMA call to look up
aliases) with the one-liner pattern used across closest-preview, slack, braze,
and other apps. The CMA fallback was fragile (aliases[0] guess) and unnecessary
— sdk.ids.environmentAlias is already populated when the user accesses via alias,
which is the case that was causing the 403.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore(drive-integration): apply prettier formatting to useWorkflowAgent.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants