Skip to content

Relative link to script blocks publishing by triggering Confluence page lookup #732

@juancarlosjr97

Description

@juancarlosjr97

Description

A Markdown file containing a relative link to a shell script (for example, [this script](./scripts/setupServiceKey.sh)) causes mark to process the non-markdown file as a candidate Confluence page, attempting metadata extraction and a Confluence page API request. This results in a build failure when the API cannot resolve the script file as a Confluence page.

Reproduction

Directory structure:

test-confluence-syndication/
├── SERVICE_KEYS.md
└── scripts/
   └── setupServiceKey.sh

SERVICE_KEYS.md content:

# SERVICE_KEYS Testing

This is a test document with a relative link to [this script](./scripts/setupServiceKey.sh).

scripts/setupServiceKey.sh content:

#!/usr/bin/env bash
echo "test"

Run mark (v15.3.0):

docker run --rm -it -v "$PWD:/work" -w /work \
 kovetskiy/mark@sha256:5946929029b861ca89a46828292273a19d5694c833a4c07b5bd4c33660ea19b2 \
 mark --log-level TRACE \
   -b "https://confluence.example.com/wiki" \
   -u "user@example.com" \
   -p "YOUR_TOKEN" \
   --title-from-h1 \
   --space "YOUR_SPACE" \
   --parents "Parent Page" \
   -f "./SERVICE_KEYS.md"

Observed Behaviour

TRACE found a relative link: full=./scripts/setupServiceKey.sh filename=./scripts/setupServiceKey.sh hash=
TRACE filepath: scripts/setupServiceKey.sh
TRACE extracted metadata: space=~5c66e71d9f5b482e28d63e77 title=/usr/bin/env bash
TRACE rest: GET /wiki/rest/api/content/?expand=ancestors%2Cversion&spaceKey=~5c66e71d9f5b482e28d63e77&title=%2Fusr%2Fbin%2Fenv+bash&type=page
FATAL unable to resolve relative links
└─ resolve link: "./scripts/setupServiceKey.sh"
   └─ find confluence page: scripts/setupServiceKey.sh / ~5c66e71d9f5b482e28d63e77 / /usr/bin/env bash
      └─ api: find page
         └─ the Confluence API returned unexpected status: 403 Forbidden

Root Cause

Mark treats the shell script as a markdown file:

  1. Detects the relative link ./scripts/setupServiceKey.sh
  2. Attempts to extract metadata from the script file
  3. Uses the shebang line #!/usr/bin/env bash as the page "title"
  4. Tries to find a Confluence page with the title /usr/bin/env bash
  5. Fails with 403 error

Expected Behaviour

Relative links to non-markdown files (e.g., .sh, .py, .txt) should not be treated as Confluence pages and should not block publishing.

Environment

  • Mark version: v15.3.0
  • Docker digest: sha256:5946929029b861ca89a46828292273a19d5694c833a4c07b5bd4c33660ea19b2
  • Confluence: Cloud (A disposable Confluence created only to test 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