发布

  • [OPIK-4935] [BE] feat(api): add project_name and project_id scoping to prompt version endpoints (#5736)

    frostbyte_neo 发布于 2026-03-19 15:45:34 +00:00

    • [OPIK-4935] [BE] feat(api): add project_name and project_id scoping to prompt version endpoints

    Add project_name and project_id fields to POST /v1/private/prompts/versions/retrieve
    and POST /v1/private/prompts/versions, allowing callers to scope prompt lookups
    and creation to a specific project.

    • PromptVersionRetrieve: add optional project_name (filters lookup to given project)
    • CreatePromptVersion: add optional project_id (takes precedence) and project_name
    • PromptService: extract resolveProjectId() helper; use strict DAO lookup in
      retrievePromptVersion to prevent fallback to workspace-level when project_name
      is explicitly provided; validate project_id existence when supplied
    • PromptResourceTest: update all PromptVersionRetrieve call sites to use builder,
      add project_name scoping and validation tests

    Implements OPIK-4935

    • fix(prompts): throw NotFoundException when project_name is provided but not found in retrieve

    • fix(prompt): restore workspace-level fallback in retrievePromptVersion

    Use the private findByName helper (which already handles the
    project → workspace fallback) instead of calling promptDAO.findByName
    directly, so retrieval behaves consistently with the creation path.

    • test(prompt): update retrieve fallback test to match workspace-wide fallback design

    When the project-level lookup misses, retrievePromptVersion falls back
    to a workspace-wide search. Updated the test to assert 200 (found via
    fallback) instead of 404.

    • test(prompt): add missing retrieve scenarios for project-scope fallback
    • workspace-level prompt found when projectName is specified (fallback)
    • 404 when projectName does not exist in the workspace
    • [OPIK-4981] [BE] Fall back to workspace-wide in retrievePromptVersion when project not found

    When projectName is provided but does not resolve to an existing project,
    pass null as projectId so the lookup falls through to workspace-wide search
    instead of throwing 404.

    下载附件