---
title: Missing or broken book images
summary: Resolve book images that fail to load or whose blob is missing.
version: 1.0.0
type: runbooks
order: 3
badges:
  - content: Runbook
    backgroundColor: orange
    textColor: orange
---

## Trigger / Symptom & Blast Radius

A book cover image returns HTTP `403` or `404` in Storefront or Backoffice, or [[service|catalog-api]] logs URN resolution errors. [[service|catalog-api]] stores an internal URN in [[container|catalog-database]] and signs short-lived, read-only SAS URLs (1-hour default) for [[container|catalog-blob]]. Blast radius is limited to cover image rendering; catalog metadata and checkout remain unaffected.

<Admonition type="danger">
	Do not hand-edit the `image` column in [[container|catalog-database]] unless executing an approved
	migration remediation. Manual edits bypass URN validation and can orphan blobs in
	[[container|catalog-blob]].
</Admonition>

## Pre-Flight Check

Fetch a fresh book payload to rule out a client-cached expired SAS URL, and inspect the stored URN in [[container|catalog-database]]:

```bash
IMAGE_URL=$(curl -sS "https://<GATEWAY_HOST>/catalog/api/v1/books/<BOOK_ID>" | jq -r '.imageUrl')
curl -I "$IMAGE_URL"
```

```sql
SELECT id, name, image, is_deleted FROM books WHERE id = '<BOOK_ID>';
```

## Quick Recovery Procedure

<Steps>
<Step title="Verify whether the blob exists in Azure Blob Storage">

Extract `<BLOB_NAME>` (the fourth colon-delimited segment of the stored URN) and check [[container|catalog-blob]]:

```bash
az storage blob exists \
  --account-name <STORAGE_ACCOUNT> \
  --container-name catalog-blob \
  --name <BLOB_NAME> \
  --auth-mode login
```

</Step>
<Step title="Check Managed Identity RBAC if SAS returns 403 immediately">

If a freshly generated SAS URL returns `403`, confirm the [[service|catalog-api]] Managed Identity holds `Storage Blob Data Contributor` and `Storage Blob Delegator` roles on `<STORAGE_ACCOUNT>`.

</Step>
<Step title="Restore or replace the missing blob">

**Backup available:** Restore the blob to the exact same `<STORAGE_ACCOUNT>`, `catalog-blob` container, and `<BLOB_NAME>` so the existing URN works without database changes.

**Blob unrecoverable:** Upload a replacement cover (`image/jpeg`, `image/png`, or `image/webp`) through Backoffice or `PUT /catalog/api/v1/books` so [[service|catalog-api]] writes a new blob and updates the URN atomically.

</Step>
</Steps>

## Verification

Re-fetch the book through the API Gateway and confirm the signed SAS URL returns HTTP `200 OK`:

```bash
IMAGE_URL=$(curl -sS "https://<GATEWAY_HOST>/catalog/api/v1/books/<BOOK_ID>" | jq -r '.imageUrl')
curl -I "$IMAGE_URL"
```

Expected output:

```text
HTTP/2 200
content-type: image/webp
```

## Rollback / Escalation

- **Rollback:** Re-uploading through [[service|catalog-api]] is atomic; retain the previous image file if reverting a cover change.
- **Escalation:** Escalate storage RBAC or cross-environment URN mismatch issues to [[team|platform-engineering-team]].

<AccordionGroup>
<Accordion title="Troubleshooting edge cases">

| Symptom                                         | Cause                                                        | Fix                                                                 |
| :---------------------------------------------- | :----------------------------------------------------------- | :------------------------------------------------------------------ |
| Image URL returns `403` after 1 hour            | Client cached a short-lived SAS URL past expiry              | Re-fetch the book from [[service\|catalog-api]]; fix client caching |
| `403` immediately after generation              | Managed Identity lacks User Delegation Key RBAC              | Grant `Storage Blob Delegator` and `Storage Blob Data Contributor`  |
| `UrnException` in [[service\|catalog-api]] logs | Database restored from another environment's storage account | Align blobs and update URNs via approved remediation                |

</Accordion>
</AccordionGroup>

## Related documentation

- [[adr|adr-005-blob-storage-for-book-images]] — URN storage model and short-lived SAS design.
