Skip to content

fix: improve error handling and logging for asset downloads and tags [AIS-159]#2339

Open
ethan ozelius (ethan-ozelius-contentful) wants to merge 6 commits into
mainfrom
logging-error-handling-improvments
Open

fix: improve error handling and logging for asset downloads and tags [AIS-159]#2339
ethan ozelius (ethan-ozelius-contentful) wants to merge 6 commits into
mainfrom
logging-error-handling-improvments

Conversation

@ethan-ozelius-contentful

@ethan-ozelius-contentful ethan ozelius (ethan-ozelius-contentful) commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

AIS-97

Summary

Addresses all five Tier 1 bug fixes from AIS-97 — silent failures and crashes in asset downloads and space data fetching.

  • Fix TypeError crash in `downloadAsset` when there is no HTTP response (ECONNRESET, DNS failure, timeout) — previously `axiosError.response.status` threw unconditionally, masking the real error
  • Include asset ID, URL, HTTP status, and original error message in all download failure messages; emit failures via `logEmitter` so they land in the error log file rather than only flashing in task output
  • Add default 30s timeout to asset downloads — `options.timeout` was `undefined` by default, causing axios to never time out on hung connections
  • Add retry logic to asset downloads via `axios-retry` — 3 attempts with exponential backoff, retrying on network errors, 5xx, and 429; logs a warning on each retry via `logEmitter`
  • Fix silent tags API failure — catch handler now emits a `warning` log instead of discarding the error entirely
  • Fix editor interface warning logging `[object Object]` — template literal now uses `contentType.name || contentType.sys.id`
File Fix Ticket
`download-assets.js` Fixed TypeError crash when HTTP response is absent — guards on `axiosError.response`, wraps both error paths with asset ID + URL + original error as `{ cause }` AIS-157
`download-assets.js` Threaded `assetId` through download options so all error messages include the asset ID AIS-157
`download-assets.js` Added `logEmitter` import and emit error from the catch handler — failures now land in the error log file, not just flash in the Listr spinner AIS-157
`download-assets.js` Added default 30s timeout (`DEFAULT_DOWNLOAD_TIMEOUT_MS`) — applies to time-to-first-byte, so large file transfers are unaffected; user-supplied `options.timeout` overrides AIS-158
`download-assets.js` Added `axios-retry` with exponential backoff (3 retries by default, respects `options.retryLimit`); retries on network errors, 5xx, and 429; logs a warning per retry AIS-161
`get-space-data.js` Tags catch handler now emits a warning log with the error message instead of silently swallowing it AIS-159
`get-space-data.js` Fixed editor interface warning logging `[object Object]` → `contentType.name || contentType.sys.id` AIS-160

Test plan

  • Simulate ECONNRESET during asset download — verify error message includes asset ID, URL, and original error; verify it appears in the error log file
  • Simulate HTTP 404/500 during asset download — verify error message includes asset ID, URL, and HTTP status + statusText
  • Simulate a transient 503 during asset download — verify retry warnings are logged and the download eventually succeeds
  • Simulate a hung connection (no response) — verify the 30s timeout fires and the error is logged with asset ID and URL
  • Run export against a space with tags — verify tags export successfully
  • Temporarily break the tags API (invalid token, etc.) — verify a warning is logged and export continues with empty tags rather than silently succeeding
  • Verify editor interface warning log shows content type name/ID instead of `[object Object]`
  • Verify asset download error count in end-of-run summary table still increments correctly

Generated with Claude Code

- Fix TypeError crash in downloadAsset when HTTP response is absent
  (ECONNRESET, DNS failure, timeout) — now wraps with asset ID, URL,
  and original error as { cause }
- Add asset ID and URL to all download error messages for traceability
- Emit download errors via logEmitter so they appear in the error log
  file, not just transiently in task output
- Add default asset download timeout to prevent indefinite hangs
- Emit warning log when tags fetch fails instead of silently returning
  empty array
- Fix editor interface warning logging [object Object] — now uses
  contentType.name || contentType.sys.id

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ethan-ozelius-contentful ethan ozelius (ethan-ozelius-contentful) changed the title fix: improve error handling and logging for asset downloads and tags [AIS-97] fix: improve error handling and logging for asset downloads and tags [AIS-159] Jul 8, 2026
Ethan Ozelius (eozelius) and others added 2 commits July 8, 2026 17:44
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rapping error message

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@@ -46,7 +47,10 @@ async function downloadAsset ({ url, directory, httpClient }) {
* @type {import('axios').AxiosError}
*/
const axiosError = e

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Quick type safety check before logging, otherwise throw an error we know will be safe.

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