Skip to content

bug(confluence): markdown attachment images show "Preview unavailable" after update_page #1175

@kbichave

Description

@kbichave

Summary

When using confluence_update_page with content_format="markdown", any image referencing a page attachment by filename (e.g. ![alt](figure.png)) is silently converted to a raw HTML <img> tag. Confluence cannot resolve bare filenames as page attachments, so every such image renders as "Preview unavailable" on the published page.

This is a silent data-corruption bug — the tool succeeds, returns no error, and the page looks fine in the API response. The breakage is only visible when a human opens the page.

Steps to reproduce

  1. Attach an image (chart.png) to a Confluence page.
  2. Call confluence_update_page with content_format="markdown" and content:
    ![Revenue chart](chart.png)
  3. Open the page in Confluence → image slot shows "Preview unavailable".

Root cause

The markdown→storage conversion (via md2conf) emits:

<img alt="Revenue chart" src="chart.png"/>

Confluence Storage Format does not support <img src="..."> for page attachments. The correct representation is:

<ac:image ac:alt="Revenue chart">
  <ri:attachment ri:filename="chart.png"/>
</ac:image>

External URLs (src="https://...") render fine — only bare filenames and relative paths are affected.

Fix

Post-process the storage HTML from markdown_to_confluence_storage to replace bare-filename <img> tags with ac:image / ri:attachment macros. External URLs and absolute paths pass through unchanged.

I have a working fix with regression tests and will submit a PR linked to this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions