Repository navigation
fix(failurelogs): name the app under test in App Automate log results - #614
Conversation
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>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
sarve-shreyas
left a comment
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
| validLogTypes.some((logType) => logType !== SessionVideoLogType) | ||
| ) { | ||
| try { | ||
| app = (await readAppAutomateSession(args.sessionId, config))?.app; |
There was a problem hiding this comment.
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}.`; |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Re-reviewed cac1422..1bf2985. Build passes and the full suite passes locally (168 files, 2648 tests, 3 new).
Resolved:
- Double read:
detectSessionnow returnsappfrom the same read, and both detection paths setapp/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
left a comment
There was a problem hiding this comment.
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.
What
getFailureLogsresults for App Automate sessions now start with the app the session ran: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 asapp_details.app_name, andgetFailureLogsalready reads that endpoint to find the build.resolveBuildIdFromSessionandresolveAppAutomateBuildIdkeep their behaviour; both now read throughreadSessionDetails.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_detailsparsed into id, version and file name; absent when the session has none.npm run buildpasses on Node 22.🤖 Generated with Claude Code