Skip to content

Fix: double-encode slashes in prompt template and workflow path segments#183

Open
getpancake[bot] wants to merge 1 commit into
masterfrom
fix/slash-in-prompt-template-names
Open

Fix: double-encode slashes in prompt template and workflow path segments#183
getpancake[bot] wants to merge 1 commit into
masterfrom
fix/slash-in-prompt-template-names

Conversation

@getpancake
Copy link
Copy Markdown

@getpancake getpancake Bot commented May 21, 2026

Problem

Prompt template names (and workflow names) that contain / — e.g. feature1/resolve_problem_2 — cause 404 errors because the URL is built as:

/prompt-templates/feature1/resolve_problem_2

The proxy/router sees two path segments after /prompt-templates/, so the request never reaches the handler for a single :promptName segment.

Root cause

A plain encodeURIComponent call does not encode /; the slash passes through literally and splits the URL path.

Fix

Double-encode / characters by applying encodeURIComponent(value).replace(/%2F/gi, "%252F"). This way:

  1. After one proxy decode pass, the server receives %2F (still a single path segment).
  2. Flask (or the destination framework) then decodes %2F/ inside the named path variable, restoring the original name.

A small encodePathSegment helper was extracted at the top of utils.ts and used in both affected call sites:

  • getPromptTemplateprompt-templates/:name endpoint
  • workflow run — workflows/:name/run endpoint

Tests

Added src/utils/utils.test.ts with:

  • Unit tests for encodePathSegment (slashes, multiple slashes, no-op for clean names, spaces, lone slash)
  • Mock-based integration tests that verify the fetch URL contains %252F when a slash is in the prompt name

All 110 tests pass (npx vitest run).

Related

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.

0 participants