<@ULVA73B9P> when I deploy a model, there are some...
# ask-marvin
i
@Marvin when I deploy a model, there are some parameters inside Pydantic objects whose "description" have double backslashes. They are converted to single backslash in the Prefect dashboard. How to solve this?
m
thought for 282.9 seconds
Thanks for reporting this. A couple of quick notes and a likely fix: - In Prefect 3.x, parameter descriptions are rendered as plain text in the UI (no Markdown), so the dashboard itself should not be collapsing backslashes. - Most “lost backslash” issues come from how the Python string is authored before it ever reaches Prefect. If you intend to display a literal backslash, make sure you are using either a raw string or properly escaped backslashes in your Pydantic
Field(description=...)
(and in any docstrings that Prefect parses for descriptions). Try one of these patterns for descriptions that must show double backslashes (e.g., UNC paths, regex, Windows paths):
Copy code
from pydantic import BaseModel, Field

class Config(BaseModel):
    # Use a raw string
    unc_path: str = Field(
        default=r"\\server\share\folder",
        description=r"UNC path like \\server\share\folder"
    )

    # Or, escape backslashes explicitly
    windows_path: str = Field(
        default="C:\\Users\\name\\file.txt",
        description="Windows path like C:\\Users\\name\\file.txt"
    )
If you still see single backslashes after doing the above, could you share: - Your Prefect version (Cloud/Server and UI build if possible) - How you’re setting the description (Pydantic
Field(description=...)
vs docstring) - A minimal reproducible snippet of the model/parameter - A screenshot of how it appears in the dashboard With that, I can reproduce and file a bug if needed.
i
@Marvin The server is 3.4.8 , the client is 3.6.1 and the deployments are generated from a pyhon script with a computed "description" field which, when printed, clearly shows the double backslash.
Copy code
data_version_description = (
    'Versión de los datos a usar. Si no se indica, se usará la versión más reciente. '
    'Para ver la lista de versiones disponibles, consultar: '
    f'{str(path2windows(settings.raw_path))}'
)


class DataVersionParameters(BaseModel):
    data_version: Optional[str] = Field(
        default=None,
        description=data_version_description,
        title='Versión de los datos'
    )
When print(data_version_description) I get:
Versión de los datos a usar. Si no se indica, se usará la versión más reciente. Para ver la lista de versiones disponibles, consultar: \\san0101\IA_common$\INPUT\RAW
m
thought for 250.1 seconds
Thanks for the details — that helps. There are two different renderers in the Prefect UI that matter here: 1) Parameter help text (the small gray text next to inputs in the run form) - Rendered as plain text (no Markdown). - Double backslashes should be preserved here. - If you’re seeing them collapse in this specific spot, that’s unexpected — please share a screenshot and I can reproduce on 3.4.8 UI. 2) Flow/Deployment descriptions (the long description shown on the flow/deployment page and in some dialogs) - Rendered as Markdown. - In CommonMark, a backslash escapes a backslash. So
\\
becomes
\
during rendering. - This matches what you’re seeing with the UNC path:
\\san0101\IA_common$\INPUT\RAW
→ the leading
\\
gets rendered as a single
\
. Workarounds/fixes: - Best: wrap the path in backticks so Markdown treats it as code and preserves the backslashes.
Copy code
data_version_description = (
      'Versión de los datos a usar. Si no se indica, se usará la versión más reciente. '
      'Para ver la lista de versiones disponibles, consultar: '
      f'`{str(path2windows(settings.raw_path))}`'
  )
- Alternative if you can’t use backticks: double the backslashes for Markdown input (so it renders back to two). For example:
Copy code
safe_path = str(path2windows(settings.raw_path)).replace("\\", "\\\\")
  data_version_description = f'... consultar: {safe_path}'
This is only needed where the UI uses Markdown (flow/deployment descriptions). Next steps: - Can you confirm exactly where you see the single backslash — in the run form’s parameter help text or in the flow/deployment description area? A screenshot would help. - If it’s in the parameter form (plain text renderer), I’ll reproduce on 3.4.8 and open a bug. If it’s in the deployment/flow description, the backticks fix above will solve it.
i
@Marvin it's in the run form:
m
thought for 118.4 seconds
Got it — thanks for confirming it’s in the run form. On current UI builds the run-form description should be rendered as plain text (no Markdown), so double backslashes should be preserved. Since you’re on Server 3.4.8, it’s possible that specific UI build was still running descriptions through a Markdown renderer in the form, which would collapse
\\
\
. Quick ways to make it display correctly now: - Easiest: wrap the path in backticks so any Markdown renderer preserves it
Copy code
data_version_description = (
    'Versión de los datos a usar. Si no se indica, se usará la versión más reciente. '
    'Para ver la lista de versiones disponibles, consultar: '
    f'`{str(path2windows(settings.raw_path))}`'
)
- Or, pre-escape backslashes (works for Markdown-rendered UIs)
Copy code
safe_path = str(path2windows(settings.raw_path)).replace("\\", "\\\\")
data_version_description = (
    'Versión de los datos a usar. Si no se indica, se usará la versión más reciente. '
    'Para ver la lista de versiones disponibles, consultar: '
    f'{safe_path}'
)
- If you must show a leading UNC
\\
exactly as two characters even under Markdown, a robust trick is to insert a zero‑width space between them (renders the same visually, prevents collapse):
Copy code
safe_path = str(path2windows(settings.raw_path)).replace("\\\\", "\\\u200b\\")
data_version_description = f'... consultar: {safe_path}'
Could you also help me isolate whether it’s the backend or UI doing this? - Open DevTools → Network, load the run form, and inspect the schema/parameters request. Check the
description
value for your parameter — does it show
\\
or
\
? - If the API returns
\\
but the UI shows
\
, I’ll file a UI bug for the 3.4.8 build. A screenshot of the run form and the UI build/hash (Help → About) would be perfect. - If the API already returns a single backslash, I’ll trace where the description is being transformed on the server side. If upgrading Server is an option, moving to a newer 3.6.x Server (which includes a newer UI) may avoid this without workarounds. In the meantime, the backticks or pre-escape approach above should resolve it.