santifer/career-ops · error · Error

Unsupported profile photo format

Error message

Unsupported profile photo format: ${photo} (expected PNG, JPEG, WebP, or GIF)

What it means

Extension check in the CV HTML builder: the photo resolves to a local file path, but its extension is not in PHOTO_MIME_BY_EXT (only .png, .jpg/.jpeg, .webp, .gif map to a MIME type), so the builder cannot embed it. A file exists at the path but its format is unrecognized (e.g. .svg, .avif, .bmp, or a path whose extension was mistyped).

Solutions

  1. Convert the photo to PNG, JPEG, WebP, or GIF and update the path
  2. Fix a mistyped extension that doesn't match the actual file format
  3. Move the image to an https URL or data URL if conversion isn't possible
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at build-cv-html.mjs:150 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of santifer/career-ops@e7abd431fc (2026-09-16). Data as JSON: /api/errors/726f4811c24edd9e. Report an issue: GitHub.

Appendix: source

Thrown at build-cv-html.mjs:150

      throw new Error('Unsupported profile photo data URL (expected base64 PNG, JPEG, WebP, or GIF)');
    }
    c.photo = photo;
    return c;
  }

  if (/^https?:\/\//i.test(photo)) {
    c.photo = photo;
    return c;
  }

  if (/^[a-z][a-z0-9+.-]+:/i.test(photo)) {
    throw new Error(`Unsupported profile photo URL scheme: ${photo.split(':', 1)[0]}`);
  }

  const photoPath = isAbsolute(photo) ? photo : resolve(__dirname, photo);
  const mime = PHOTO_MIME_BY_EXT.get(extname(photoPath).toLowerCase());
  if (!mime) {
    throw new Error(`Unsupported profile photo format: ${photo} (expected PNG, JPEG, WebP, or GIF)`);
  }

  let bytes;
  try {
    bytes = await readFile(photoPath);
  } catch (err) {
    throw new Error(`Profile photo not found or unreadable: ${photo} (${err.code || err.message})`);
  }
  if (bytes.length === 0) {
    throw new Error(`Profile photo is empty: ${photo}`);
  }
  c.photo = `data:${mime};base64,${bytes.toString('base64')}`;
  return c;
}

function joinItems(items) {
  if (Array.isArray(items)) return items.join(', ');
  return typeof items === 'string' ? items : '';

View on GitHub (pinned to e7abd431fc)