Skip to content

fix(failurelogs): name the app under test in App Automate log results - #614

Merged
Dave3130 merged 2 commits into
browserstack:mainfrom
SavioBS629:fix/app-automate-app-details
Nov 27, 2026
Merged

Dave3130 merged 2 commits into
browserstack:mainfrom
SavioBS629:fix/app-automate-app-details

Conversation

@SavioBS629

Copy link
Copy Markdown
Collaborator

What

getFailureLogs results for App Automate sessions now start with the app the session ran:

App under test: com.browserstack.Sample-iOS (bundle id on iOS, package name on Android), version 1.0, uploaded as BStackSampleApp.ipa.

The Appium, device and crash logs do not carry the app's bundle id, so an agent debugging an iOS failure had no way to name the app. The session details endpoint (/app-automate/sessions/{id}.json) returns it as app_details.app_name, and getFailureLogs already reads that endpoint to find the build.

  • When the build id is resolved from the session, the same response gives the app: no extra request.
  • When the caller passes the build id, the session details are read once for the app.
  • If that read fails, the logs are returned as before, without the line.
  • Automate sessions and video-only requests are unchanged.

resolveBuildIdFromSession and resolveAppAutomateBuildId keep their behaviour; both now read through readSessionDetails.

Tests

  • tests/tools/getFailureLogs.test.ts: the app line comes first and from the same session read that finds the build; one read when the build id is supplied; logs without the line when the read fails; no read for Automate sessions.
  • tests/tools/resolve-hashed-build-id.test.ts: app_details parsed into id, version and file name; absent when the session has none.
  • Checked live on iOS 16 to 18 and Android 13 App Automate sessions.
  • npm run build passes on Node 22.

🤖 Generated with Claude Code

getFailureLogs now starts App Automate results with the app the session ran:
its bundle id (package name on Android), version and uploaded file name, read
from the session details it already uses to find the build. When the caller
passes the build id, the session details are read once for the app; if that
read fails, the logs are returned without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto (fallback from Default branch)
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML (base), Organization UI (inherited), Workspace UI (inherited); Enforced overrides: Organization
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: dbd25e6d-729f-410d-b19d-cbd756a0e3d3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@sarve-shreyas sarve-shreyas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full diff at cac1422 against main. npm run build passes and the full vitest suite passes locally (168 files, 2645 tests).

No blocking issues. The change is well contained: resolveBuildIdFromSession / resolveAppAutomateBuildId keep their contracts (fetch-screenshots.ts is unaffected), a 404 or non-App-Automate session never gets the line, and the best-effort read cannot fail the call. I also checked the telemetry side: a failed best-effort read records its status via apiClient, but the log fetches that follow overwrite it, so it does not count against MCP stability when the logs come back.

Three non-blocking notes inline: an avoidable second session read when the session went through detectSession, the extra sequential round-trip when the caller passes buildId, and the platform wording in the app line.

let sessionRead = false;
if (sessionType === SessionType.AppAutomate && needsBuildId && !buildId) {
buildId = await resolveAppAutomateBuildId(args.sessionId, config);
const details = await readAppAutomateSession(args.sessionId, config);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: only this branch keeps the app from the read. detectSession (used at L116 when the log types don't fit the given sessionType, and at L135 as the fallback) goes through resolveBuildIdFromSession, which drops app, so sessionRead stays false and L184 reads the same App Automate session a second time.

Scenario: agent calls with sessionType: automate, logTypes: [deviceLogs] on an App Automate session → detectSession reads /app-automate/sessions/{id}.json (finds the build), then the app block reads it again.

Suggestion: have detectSession return the SessionDetails it already has ({ sessionType, hashedBuildId, app }) and set app/sessionRead from it.

Comment thread src/tools/get-failure-logs.ts Outdated
validLogTypes.some((logType) => logType !== SessionVideoLogType)
) {
try {
app = (await readAppAutomateSession(args.sessionId, config))?.app;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: when the caller supplies buildId this adds a sequential round-trip before any log is fetched. Since it is best-effort and independent of the logs, it could be started here as a promise (with its own .catch(() => undefined)) and awaited just before building the preface, so it overlaps with the log downloads.

function describeApp(app: AppUnderTest): string {
const version = app.version ? `, version ${app.version}` : "";
const file = app.filename ? `, uploaded as ${app.filename}` : "";
return `App under test: ${app.id} (bundle id on iOS, package name on Android)${version}${file}.`;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: (bundle id on iOS, package name on Android) is printed on every result regardless of platform. If the session details carry the OS (e.g. os on automation_session), naming it once (bundle id / package name) would read cleaner. Fine to leave as is if the field isn't reliable.

…alongside the logs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@sarve-shreyas sarve-shreyas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed cac1422..1bf2985. Build passes and the full suite passes locally (168 files, 2648 tests, 3 new).

Resolved:

  • Double read: detectSession now returns app from the same read, and both detection paths set app / sessionRead, so the session is read once. Covered by the new detection test.
  • Latency: the app read starts before the log loop and is awaited after it, so it overlaps with the log downloads. The IIFE catches its own errors, so a thrown log fetch leaves no unhandled rejection. I also checked telemetry: a failed call is attributed from the thrown error's own status first, so the overlapping read doesn't change how failures are recorded.

Deferred by the author: the platform-wording nit.

No remaining findings from my side.

@sarve-shreyas sarve-shreyas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 1bf2985. Double session read and the sequential app read are fixed; the platform-wording nit was left by the author, which is fine.

@Dave3130
Dave3130 merged commit db201a2 into browserstack:main Nov 27, 2026
4 checks passed
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.

3 participants