Fix: double-encode slashes in prompt template and workflow path segments#183
Open
getpancake[bot] wants to merge 1 commit into
Open
Fix: double-encode slashes in prompt template and workflow path segments#183getpancake[bot] wants to merge 1 commit into
getpancake[bot] wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Prompt template names (and workflow names) that contain
/— e.g.feature1/resolve_problem_2— cause 404 errors because the URL is built as:The proxy/router sees two path segments after
/prompt-templates/, so the request never reaches the handler for a single:promptNamesegment.Root cause
A plain
encodeURIComponentcall does not encode/; the slash passes through literally and splits the URL path.Fix
Double-encode
/characters by applyingencodeURIComponent(value).replace(/%2F/gi, "%252F"). This way:%2F(still a single path segment).%2F→/inside the named path variable, restoring the original name.A small
encodePathSegmenthelper was extracted at the top ofutils.tsand used in both affected call sites:getPromptTemplate—prompt-templates/:nameendpointworkflows/:name/runendpointTests
Added
src/utils/utils.test.tswith:encodePathSegment(slashes, multiple slashes, no-op for clean names, spaces, lone slash)fetchURL contains%252Fwhen a slash is in the prompt nameAll 110 tests pass (
npx vitest run).Related