Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
342 commits
Select commit Hold shift + click to select a range
d70837c
Test each saved target URL rule on its own
varunj-msft Nov 5, 2026
4ce3214
Describe what a saved target can use more precisely
varunj-msft Nov 5, 2026
5669748
Merge the saved target rule tests and doc
varunj-msft Nov 5, 2026
1ef0838
Describe saving targets more precisely
varunj-msft Nov 5, 2026
b3b8ac5
Test the remaining saved target URL rules on their own
varunj-msft Nov 6, 2026
8a44952
Say which saved target addresses are checked
varunj-msft Nov 6, 2026
14125fc
Merge the remaining saved target rule tests and doc
varunj-msft Nov 6, 2026
078dc72
Describe what saving a target refuses more precisely
varunj-msft Nov 6, 2026
6800d15
Merge origin/main
varunj-msft Nov 6, 2026
74839cd
Merge origin/main
varunj-msft Nov 6, 2026
ee3e64f
Merge origin/main
varunj-msft Nov 6, 2026
15e7a9e
Take out the restore retry changes merged here by mistake
varunj-msft Nov 6, 2026
368b914
Merge origin/main
varunj-msft Nov 6, 2026
fd7bd4a
Merge origin/main
varunj-msft Nov 6, 2026
844a424
Say a Temporary target is also gone after a reinitialization
varunj-msft Nov 6, 2026
ebd1042
Say which target types can be saved, and mark a refused save
varunj-msft Nov 6, 2026
d3a8d2e
Save targets from the New Target dialog and label where each comes from
varunj-msft Nov 6, 2026
7d9ac2f
Log why storage is unavailable, without its path or URL
varunj-msft Nov 7, 2026
7b5bfeb
Merge the storage error logging
varunj-msft Nov 7, 2026
22806d8
Merge the storage error logging
varunj-msft Nov 7, 2026
34011c9
Hide a restore message with a percent escape, which can hide a creden…
varunj-msft Nov 7, 2026
8a0113f
Merge the storage error logging and the percent-escape fix
varunj-msft Nov 7, 2026
8d51b6c
Merge the storage error logging and the percent-escape fix
varunj-msft Nov 7, 2026
6ddd960
Merge the storage error logging and the percent-escape fix
varunj-msft Nov 7, 2026
91bb36b
Merge the storage error logging and the percent-escape fix
varunj-msft Nov 7, 2026
ad7cb29
Merge the storage error logging and the percent-escape fix
varunj-msft Nov 7, 2026
dc4125c
Stop a launch whose script catches the duplicate-name error for a sav…
varunj-msft Nov 7, 2026
febc8c3
Merge the duplicate-name refusal for saved entries
varunj-msft Nov 7, 2026
303dfa8
Merge the duplicate-name refusal for saved entries
varunj-msft Nov 7, 2026
6abde9f
Merge the duplicate-name refusal for saved entries
varunj-msft Nov 7, 2026
e03fd18
Merge origin/main
varunj-msft Nov 7, 2026
36462db
Merge origin/main
varunj-msft Nov 7, 2026
37f9522
Merge origin/main
varunj-msft Nov 7, 2026
031dc61
Merge origin/main
varunj-msft Nov 8, 2026
7f8ab0d
Merge origin/main
varunj-msft Nov 8, 2026
19205b1
Import the saved recipe models from their package, as main now requires
varunj-msft Nov 8, 2026
0348a0b
Merge origin/main
varunj-msft Nov 8, 2026
bba3afd
Import from public packages, as main now requires
varunj-msft Nov 8, 2026
d4ccd50
Merge origin/main
varunj-msft Nov 8, 2026
ed01798
Merge origin/main
varunj-msft Nov 8, 2026
98766ec
Record a saved entry's name clash wherever a launch script can catch it
varunj-msft Nov 8, 2026
6fb1e00
Merge origin/main
varunj-msft Nov 8, 2026
405c2bd
Import from public packages, as main now requires
varunj-msft Nov 8, 2026
d35eea9
Merge origin/main
varunj-msft Nov 8, 2026
9afbd2c
Merge origin/main
varunj-msft Nov 8, 2026
13bd3ab
Check a target that takes no credentials as the default auth mode
varunj-msft Nov 8, 2026
2b97d83
Merge origin/main
varunj-msft Nov 8, 2026
aaf2c15
Merge origin/main
varunj-msft Nov 8, 2026
e9cf3f0
Require a name when the API registers a target
varunj-msft Nov 8, 2026
cf2d89b
Require a name in the frontend's create-target request
varunj-msft Nov 8, 2026
622bbb8
Report storage failures with one error and answer them with 503
varunj-msft Nov 9, 2026
1cae0b9
Merge the single storage error
varunj-msft Nov 9, 2026
eba7bf2
Escape file names once and simplify the saved recipe models
varunj-msft Nov 9, 2026
9f24124
Merge the recipe model simplification
varunj-msft Nov 9, 2026
2bbfc8f
Report restore bugs as build errors and log each failure once
varunj-msft Nov 9, 2026
3735dbc
Merge the restore logging and build error fixes
varunj-msft Nov 9, 2026
ca7563d
Stay ready when a saved entry can't be restored, and hold its name
varunj-msft Nov 9, 2026
a9dfc86
Merge the stay-ready restore
varunj-msft Nov 10, 2026
67416f1
Reset the registries between runtime tests, as a real startup does
varunj-msft Nov 10, 2026
e6e419e
Merge the runtime test isolation
varunj-msft Nov 10, 2026
81c0317
Stop a launch whose script takes the name of a saved entry that failed
varunj-msft Nov 10, 2026
6ee84f0
Merge origin/main
varunj-msft Nov 10, 2026
d43a7e8
Merge origin/main
varunj-msft Nov 10, 2026
0664063
Merge origin/main
varunj-msft Nov 10, 2026
3b3ac59
Merge origin/main
varunj-msft Nov 10, 2026
04fe60f
Merge origin/main
varunj-msft Nov 10, 2026
6911327
Merge origin/main
varunj-msft Nov 10, 2026
ee45962
Refuse OpenAI targets while the server sets OPENAI_CUSTOM_HEADERS
varunj-msft Nov 10, 2026
6a98d17
Merge origin/main
varunj-msft Nov 10, 2026
4a3f2e5
Use final origin names, record startup entries at registration, and t…
varunj-msft Nov 10, 2026
9f5d390
Merge the saved target origin and naming changes
varunj-msft Nov 10, 2026
fa3f3ab
Merge the saved target origin and naming changes
varunj-msft Nov 10, 2026
51d4fff
Explain that a credential refusal also covers using this server's cre…
varunj-msft Nov 10, 2026
a3d4f92
Merge the credential explanation
varunj-msft Nov 10, 2026
3c7a918
Merge the credential explanation
varunj-msft Nov 10, 2026
f3a7ec2
Merge the credential explanation
varunj-msft Nov 10, 2026
8614025
Use one recipe format version, keep the auth mode, and escape failure…
varunj-msft Nov 10, 2026
5a3f18b
Merge the recipe format changes
varunj-msft Nov 10, 2026
b3c7847
Build restored entries with a builder the caller supplies
varunj-msft Nov 10, 2026
af4075f
Merge the restore builder changes
varunj-msft Nov 10, 2026
061807a
Warn that writing saved entries is administrator authority, and test …
varunj-msft Nov 10, 2026
1740964
Merge the restore builder changes
varunj-msft Nov 10, 2026
01d99d7
Merge the restore builder changes
varunj-msft Nov 10, 2026
600717f
Merge the restore builder changes
varunj-msft Nov 10, 2026
095e76b
Merge the restore builder changes
varunj-msft Nov 10, 2026
7a547aa
Say restore can't tell who wrote a saved file
varunj-msft Nov 10, 2026
f71259b
Merge the saved file wording
varunj-msft Nov 10, 2026
7d72788
Merge the restore builder changes
varunj-msft Nov 10, 2026
986cc90
Test the parser's depth limit without depending on the stack size
varunj-msft Nov 10, 2026
1096925
Merge the parser depth test fix
varunj-msft Nov 10, 2026
f25b520
Merge the parser depth test fix
varunj-msft Nov 10, 2026
1845b64
Merge the parser depth test fix
varunj-msft Nov 10, 2026
bd2224b
Merge the parser depth test fix
varunj-msft Nov 10, 2026
b454e75
Merge the parser depth test fix
varunj-msft Nov 10, 2026
83a0bca
Merge the parser depth test fix
varunj-msft Nov 10, 2026
3af240b
Merge the parser depth test fix
varunj-msft Nov 10, 2026
fb90af8
Read saved entries in a worker thread when restore isn't given what w…
varunj-msft Nov 10, 2026
c44d2ce
Merge the worker-thread read
varunj-msft Nov 10, 2026
abd116a
Stay not ready when a saved entry can't be restored, and let apply retry
varunj-msft Nov 10, 2026
0bfa6cc
Drop the refusal of held names from launches
varunj-msft Nov 10, 2026
c62118f
Merge the not-ready restore
varunj-msft Nov 10, 2026
c0aa46d
Merge the not-ready restore
varunj-msft Nov 10, 2026
f59306e
Read saved recipes off the event loop by default, and harden URL reda…
richlundeen Nov 10, 2026
7d90d68
Merge the not-ready restore
varunj-msft Nov 10, 2026
0f0c53d
Treat a class a launch script puts in place of another as temporary
varunj-msft Nov 10, 2026
26e1d0e
Merge the not-ready restore
varunj-msft Nov 10, 2026
f1ff143
Keep an "@" in a URL's path when redacting URLs in text
richlundeen Nov 10, 2026
44cd36a
Merge the not-ready restore
varunj-msft Nov 10, 2026
009e761
Merge the restore read and redaction fixes
varunj-msft Nov 10, 2026
21f22a4
Merge the restore read and redaction fixes
varunj-msft Nov 10, 2026
e9103ff
Merge the restore read and redaction fixes
varunj-msft Nov 10, 2026
57b069a
Merge the restore read and redaction fixes
varunj-msft Nov 10, 2026
7c88228
Merge the restore read and redaction fixes
varunj-msft Nov 10, 2026
dfdfe5a
Merge the restore read and redaction fixes
varunj-msft Nov 10, 2026
cc4ae4d
Merge main
varunj-msft Nov 10, 2026
9f4c71e
Merge main
varunj-msft Nov 10, 2026
5121026
Merge main
varunj-msft Nov 10, 2026
d15f7fd
Merge main
varunj-msft Nov 11, 2026
84ad3fe
Merge main
varunj-msft Nov 11, 2026
733b537
Merge main
varunj-msft Nov 11, 2026
be0b885
Use the dialog's save button in the new tests from main
varunj-msft Nov 11, 2026
4bf0e74
Merge the dialog test fixes
varunj-msft Nov 11, 2026
187191c
Answer suite readiness storage failures through the shared storage ha…
varunj-msft Nov 11, 2026
ee8162c
Give the HTTPTarget save test the connection field a create now needs
varunj-msft Nov 11, 2026
bb2a620
Merge the readiness and save test fixes
varunj-msft Nov 11, 2026
db7451a
Merge the readiness and save test fixes
varunj-msft Nov 11, 2026
b200c92
Merge the readiness and save test fixes
varunj-msft Nov 11, 2026
4c42a6b
Merge the readiness and save test fixes
varunj-msft Nov 11, 2026
b8c3f0c
Merge the readiness and save test fixes
varunj-msft Nov 11, 2026
374c620
Merge main
varunj-msft Nov 11, 2026
7ac059c
Answer suite readiness storage failures through the shared storage ha…
varunj-msft Nov 11, 2026
d84395e
Name the target in the manual model test from main, since a registere…
varunj-msft Nov 11, 2026
e08b67a
Merge main
varunj-msft Nov 11, 2026
7fa4ca4
Expect storage errors from main's version-checked delete tests the wa…
varunj-msft Nov 11, 2026
9bf5886
Merge main
varunj-msft Nov 11, 2026
626d2d4
Merge main
varunj-msft Nov 11, 2026
4a86017
Merge main
varunj-msft Nov 11, 2026
9568edb
Merge main
varunj-msft Nov 11, 2026
54e4374
Merge main
varunj-msft Nov 11, 2026
21ba521
Merge main
varunj-msft Nov 11, 2026
e34258c
Fit the explicit-target E2E from main to the dialog's save button and…
varunj-msft Nov 11, 2026
5339aba
Merge the explicit-target E2E fix
varunj-msft Nov 11, 2026
c506195
Merge main
varunj-msft Nov 11, 2026
1ba526f
Merge main
varunj-msft Nov 11, 2026
9cdf7e7
Merge main
varunj-msft Nov 11, 2026
40d36ed
Merge main
varunj-msft Nov 11, 2026
6a52054
Merge main
varunj-msft Nov 11, 2026
23a7ec1
Merge main
varunj-msft Nov 11, 2026
70fbc3d
Merge main
varunj-msft Nov 11, 2026
a1e79d1
Merge main
varunj-msft Nov 11, 2026
efd5f9c
Merge main
varunj-msft Nov 11, 2026
8c517d0
Use the dialog's save button in main's endpoint tests
varunj-msft Nov 11, 2026
d76eef4
Merge the endpoint test fix
varunj-msft Nov 11, 2026
0e7a21f
Exempt the storage error handler from the keyword-only check
varunj-msft Nov 11, 2026
c35fa01
Merge keyword-only fixes
varunj-msft Nov 11, 2026
953dcce
Merge keyword-only fixes
varunj-msft Nov 11, 2026
d6079a1
Merge keyword-only fixes
varunj-msft Nov 11, 2026
21556ed
Merge keyword-only fixes
varunj-msft Nov 11, 2026
14004e9
Merge keyword-only fixes
varunj-msft Nov 11, 2026
3abc824
Merge keyword-only fixes
varunj-msft Nov 11, 2026
623fd40
Merge keyword-only fixes
varunj-msft Nov 11, 2026
b4ecc2b
Merge keyword-only fixes
varunj-msft Nov 11, 2026
bf97225
Log every problem with a saved file that isn't valid
varunj-msft Nov 11, 2026
5e6faed
Merge the full schema-validation log
varunj-msft Nov 11, 2026
7625f89
Merge the full schema-validation log
varunj-msft Nov 11, 2026
8dbd4c2
Merge the full schema-validation log
varunj-msft Nov 11, 2026
5c7223a
Merge the full schema-validation log
varunj-msft Nov 11, 2026
76e123c
Merge the full schema-validation log
varunj-msft Nov 11, 2026
35199cc
Leave the error behind a storage failure out of the logs
varunj-msft Nov 12, 2026
efcdfa9
Test a blob upload that fails with a transport or authentication error
varunj-msft Nov 12, 2026
0fdebdc
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
c413994
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
c057e30
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
dc97ec7
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
a9478df
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
dc0c058
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
8f27c91
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
9c61849
Merge the storage log and restore report fixes
varunj-msft Nov 12, 2026
c9b795a
Merge main
varunj-msft Nov 12, 2026
38c981c
Merge main
varunj-msft Nov 12, 2026
eb71448
Merge main
varunj-msft Nov 12, 2026
1be067e
Merge main
varunj-msft Nov 12, 2026
162fc2a
Merge main
varunj-msft Nov 12, 2026
6c0c3dd
Merge main
varunj-msft Nov 12, 2026
3d0950d
Merge main
varunj-msft Nov 12, 2026
8b59c5d
Merge main
varunj-msft Nov 12, 2026
3b0ada2
Merge main
varunj-msft Nov 12, 2026
4e8d9c2
Return 409 when a suite's launch scripts would replace a saved entry
varunj-msft Nov 12, 2026
b1bbbe6
Merge the suite launch conflict status
varunj-msft Nov 12, 2026
9ce29cb
Merge the suite launch conflict status
varunj-msft Nov 12, 2026
4e0e640
Merge the suite launch conflict status
varunj-msft Nov 12, 2026
5cfd456
Merge the suite launch conflict status
varunj-msft Nov 12, 2026
15e00de
Merge main
varunj-msft Nov 12, 2026
0c5baa8
Merge main
varunj-msft Nov 12, 2026
a3f65ad
Merge main
varunj-msft Nov 12, 2026
d9219f2
Merge main
varunj-msft Nov 12, 2026
d4337d8
Merge main
varunj-msft Nov 12, 2026
48bc6d1
Merge main
varunj-msft Nov 12, 2026
9789264
Merge main
varunj-msft Nov 12, 2026
d41bd98
Merge main
varunj-msft Nov 12, 2026
805ca2a
Merge main into part 7
varunj-msft Nov 13, 2026
b9c50e1
Merge part 7 into part 8
varunj-msft Nov 13, 2026
5363c0b
Merge part 8 into part 9
varunj-msft Nov 13, 2026
9b80bfd
Merge part 9 into part 16
varunj-msft Nov 13, 2026
cdbe6ad
Keep the recipe storage setup apart from the saved target requirements
varunj-msft Nov 13, 2026
450b1e5
Merge part 7 into part 8
varunj-msft Nov 13, 2026
699ab5b
Move saving a target into the registry library
varunj-msft Nov 13, 2026
7d914b1
Merge part 8 into part 9
varunj-msft Nov 13, 2026
713f7d1
Merge main into part 8
varunj-msft Nov 13, 2026
793316a
Merge part 8 into part 9
varunj-msft Nov 13, 2026
0730475
Merge part 9 into part 16
varunj-msft Nov 13, 2026
048283e
Merge main into part 8
varunj-msft Nov 13, 2026
6c243b6
Merge part 8 into part 9
varunj-msft Nov 13, 2026
3c383ce
Merge part 9 into part 16
varunj-msft Nov 13, 2026
174a1e9
Report a registered copy as a copy, not as missing a name
varunj-msft Nov 13, 2026
f273bff
Merge main into part 8
varunj-msft Nov 14, 2026
d692b25
Merge main into part 9
varunj-msft Nov 14, 2026
2110254
Merge main into part 16
varunj-msft Nov 14, 2026
54d9332
Check saved entries against restore's inputs and settle cancelled saves
varunj-msft Nov 14, 2026
0529525
Merge part 8 into part 9
varunj-msft Nov 14, 2026
d0bb066
Ask the backend whether a target's values can be saved
varunj-msft Nov 14, 2026
0c52d23
Merge part 9 into part 16
varunj-msft Nov 14, 2026
c05e125
Check saveability with a request that registers nothing
varunj-msft Nov 14, 2026
8277fac
Merge part 9 into part 16
varunj-msft Nov 14, 2026
e47689c
Wrap the saveability note in the backend README
varunj-msft Nov 14, 2026
75ac363
Merge part 16
varunj-msft Nov 14, 2026
e6cfbd9
Answer the saveability check in the numeric controls end-to-end mocks
varunj-msft Nov 14, 2026
77371e5
Merge part 16
varunj-msft Nov 14, 2026
87de386
Bound the URL scheme when redacting text
varunj-msft Nov 14, 2026
96361e5
Merge part 9
varunj-msft Nov 14, 2026
9ece6bc
Merge part 16
varunj-msft Nov 14, 2026
33650ff
Merge main into part 8
varunj-msft Nov 17, 2026
87a4abf
Merge main into part 9
varunj-msft Nov 17, 2026
b369843
Merge main into part 9
varunj-msft Nov 17, 2026
a9bd61c
Merge main into part 16
varunj-msft Nov 17, 2026
ed3141f
Merge main into part 9
varunj-msft Nov 18, 2026
f691ba6
Keep saveability available as a target name
varunj-msft Nov 18, 2026
0f8e4a4
Merge main into part 16
varunj-msft Nov 18, 2026
2c15d96
Merge main into part 9
varunj-msft Nov 19, 2026
d055396
Keep the class save rule in the library and answer with the cause alone
varunj-msft Nov 19, 2026
ca4324b
Create targets only you can use, or that allow credential updates, as…
varunj-msft Nov 19, 2026
2576497
Merge part 9 into part 16
varunj-msft Nov 19, 2026
d9a66f6
Give each reason a target stays Temporary as its cause only, and drop…
varunj-msft Nov 19, 2026
8bc4161
Say the saveability check runs create's checks on the type, parameter…
varunj-msft Nov 19, 2026
eccbc99
Merge part 9 into part 16
varunj-msft Nov 19, 2026
fa087b1
Merge main into part 9
varunj-msft Nov 19, 2026
0dc92aa
Merge main into part 9
varunj-msft Nov 19, 2026
d47beba
Merge part 9 into part 16
varunj-msft Nov 19, 2026
80f519d
Merge main into part 16
varunj-msft Nov 19, 2026
d2d7dd3
Merge main into part 16
varunj-msft Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/e2e/api.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { randomUUID } from "node:crypto";

import { test, expect } from "./_fixtures";
import { compatibilityHeaders, getCompatibilityId, mockVersion } from "./_compatibility";

Expand Down Expand Up @@ -72,6 +74,7 @@ test.describe("Targets API", () => {
test("should create and retrieve a target @seeded", async ({ request }) => {
test.setTimeout(90_000);
const createPayload = {
name: `api-${randomUUID()}`,
type: "OpenAIChatTarget",
auth_mode: "api_key",
params: {
Expand Down
1 change: 1 addition & 0 deletions frontend/e2e/chat-recovery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const test = base.extend<{ localTarget: LocalTarget; imageConverterId: string }>
const created = await request.post("/api/targets", {
headers: compatibilityHeaders(),
data: {
name: `recovery-${randomUUID()}`,
type: "OpenAIChatTarget",
auth_mode: "api_key",
params: {
Expand Down
3 changes: 2 additions & 1 deletion frontend/e2e/flows.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { randomUUID } from "node:crypto";
import { readFileSync } from "node:fs";

import {
Expand Down Expand Up @@ -71,7 +72,7 @@ async function createTarget(
): Promise<string> {
const resp = await request.post("/api/targets", {
headers: compatibilityHeaders(),
data: { type: targetType, params, auth_mode: authMode },
data: { name: `flow-${randomUUID()}`, type: targetType, params, auth_mode: authMode },
});
expect(resp.ok()).toBeTruthy();
const body = await resp.json();
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/services/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,13 @@ describe("api service", () => {
(apiClient.post as jest.Mock).mockResolvedValueOnce(mockResponse);

const result = await targetsApi.createTarget({
name: "new-target",
type: "OpenAIChatTarget",
params: { endpoint: "https://test.openai.azure.com/" },
});

expect(apiClient.post).toHaveBeenCalledWith("/targets", {
name: "new-target",
type: "OpenAIChatTarget",
params: { endpoint: "https://test.openai.azure.com/" },
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ export interface TargetListResponse {
}

export interface CreateTargetRequest {
/** Registry name; required with `persist`. */
name?: string
/** Registry name the target is registered under. */
name: string
type: string
params: Record<string, unknown>
auth_mode?: TargetAuthMode
Expand Down
16 changes: 9 additions & 7 deletions pyrit/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ overrides; reconstruction preserves declarations from the source target.
Per-send values use
[`request_generation_config` metadata](../../doc/code/targets/0_prompt_targets.md#runtime-generation-configuration).

A created target is Temporary: a restart or a configuration apply removes it. With `"persist": true` (and `register`
left on), the target is saved under `registry_recipes_source` and restored at every start, and the signed-in user is
recorded as the one who saved it. A saved target can't hold or use a key: it signs in with Microsoft Entra ID
(`"auth_mode": "identity"`, through this server's Azure identity) or needs no key. An OpenAI target's empty `headers`
is set to `"{}"` first, so a saved one doesn't send this server's `OPENAI_ADDITIONAL_REQUEST_HEADERS`. The save
itself is the registry library's `prepare_saved_params_async` and `save_then_register_async`, so Python code saves a
target the same way; the API adds the signed-in user, the configured source, and the responses below.
A registered target needs a `name` (otherwise **422**); only `"register": false`, which returns the target's
descriptor without registering it, works without one. A created target is Temporary: a restart or a configuration
apply removes it. With `"persist": true` (and `register` left on), the target is saved under `registry_recipes_source`
and restored at every start, and the signed-in user is recorded as the one who saved it. A saved target can't hold or
use a key: it signs in with Microsoft Entra ID (`"auth_mode": "identity"`, through this server's Azure identity) or
needs no key. An OpenAI target's empty `headers` is set to `"{}"` first, so a saved one doesn't send this server's
`OPENAI_ADDITIONAL_REQUEST_HEADERS`. The save itself is the registry library's `prepare_saved_params_async` and
`save_then_register_async`, so Python code saves a target the same way; the API adds the signed-in user, the
configured source, and the responses below.

| A request with `persist` that... | Gets |
|---|---|
Expand Down
16 changes: 10 additions & 6 deletions pyrit/backend/models/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,11 @@ class TargetParametersRequest(BaseModel):
class CreateTargetRequest(TargetParametersRequest, RegistrationRequest):
"""Request to create a new target instance."""

# LEGACY COMPATIBILITY: The GUI now sends a name whenever it registers a target. Requiring the name for
# registered targets would break API callers that leave it out, so that is left to a separate breaking change.
name: str | None = Field(
None,
min_length=1,
pattern=REGISTRY_INSTANCE_NAME_PATTERN,
description="Unique registry name, required with persist; when omitted, the backend generates one",
description="Unique registry name, required unless register is false",
)
persist: bool = Field(
False,
Expand Down Expand Up @@ -146,6 +144,13 @@ class CreateTargetRequest(TargetParametersRequest, RegistrationRequest):
),
)

@model_validator(mode="after")
def _validate_registration(self) -> "CreateTargetRequest":
# A copy is never registered, so the source check reports a registered copy instead.
if self.register_instance and self.name is None and self.source is None:
raise ValueError("name is required when register=true")
return self

@model_validator(mode="after")
def _validate_source(self) -> "CreateTargetRequest":
if self.source is None:
Expand All @@ -164,16 +169,15 @@ def _validate_persist(self) -> "CreateTargetRequest":
return self
if not self.register_instance:
raise ValueError("persist requires register=true")
if self.name is None:
raise ValueError("persist requires a name")
# A saved target is restored with no caller, so it would come back shared, and its credentials can't change.
if self.private:
raise ValueError("A private target can't be saved; leave out persist or private")
if self.allow_credential_updates:
raise ValueError(
"A saved target's credentials can't be updated; leave out persist or allow_credential_updates"
)
validate_registry_name(self.name)
if self.name is not None:
validate_registry_name(self.name)
return self


Expand Down
7 changes: 3 additions & 4 deletions pyrit/backend/services/target_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import asyncio
import logging
import uuid
from collections.abc import Generator, Mapping
from contextlib import contextmanager
from functools import lru_cache
Expand Down Expand Up @@ -647,10 +646,9 @@ async def create_target_async(
auth_mode=request.auth_mode,
)

# LEGACY COMPATIBILITY: Only API callers that leave out the name reach this fallback; the GUI sends one.
# Remove it when the name becomes required for registered targets.
target_registry_name = request.name or f"compat_{uuid.uuid4().hex}"
target_registry_name = request.name
if request.register_instance:
assert target_registry_name is not None # the request requires a name to register a target
try:
self._registry.instances.validate_name_available(target_registry_name)
except RegistryNameTakenError as error:
Expand Down Expand Up @@ -687,6 +685,7 @@ async def create_target_async(
)
finally:
await release_component_async(target_obj)
assert target_registry_name is not None # the request requires a name to register a target
try:
creator = creator_metadata(
name=target_registry_name,
Expand Down
25 changes: 18 additions & 7 deletions tests/unit/backend/test_api_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ def test_create_target_success(self, client: TestClient) -> None:

response = client.post(
"/api/targets",
json={"type": "TextTarget", "params": {}},
json={"name": "text_target", "type": "TextTarget", "params": {}},
)

assert response.status_code == status.HTTP_201_CREATED
Expand All @@ -1427,7 +1427,7 @@ def test_create_target_invalid_type(self, client: TestClient) -> None:

response = client.post(
"/api/targets",
json={"type": "InvalidTarget", "params": {}},
json={"name": "invalid_target", "type": "InvalidTarget", "params": {}},
)

assert response.status_code == status.HTTP_400_BAD_REQUEST
Expand All @@ -1449,7 +1449,7 @@ def test_create_target_internal_error(self, client: TestClient) -> None:

response = client.post(
"/api/targets",
json={"type": "TextTarget", "params": {}},
json={"name": "text_target", "type": "TextTarget", "params": {}},
)

assert response.status_code == status.HTTP_500_INTERNAL_SERVER_ERROR
Expand All @@ -1465,7 +1465,9 @@ def test_target_routes_pass_server_upload_folder(self, client: TestClient) -> No
mock_get_service.return_value = mock_service

types_response = client.get("/api/targets/types")
create_response = client.post("/api/targets", json={"type": "HTTPXAPITarget", "params": {}})
create_response = client.post(
"/api/targets", json={"name": "upload_target", "type": "HTTPXAPITarget", "params": {}}
)

assert types_response.status_code == status.HTTP_200_OK
assert create_response.status_code == status.HTTP_400_BAD_REQUEST
Expand All @@ -1483,7 +1485,7 @@ def test_create_target_forbids_code_execution_for_non_admin(self, client: TestCl

response = client.post(
"/api/targets",
json={"type": "HuggingFaceChatTarget", "params": {"trust_remote_code": True}},
json={"name": "remote_code", "type": "HuggingFaceChatTarget", "params": {"trust_remote_code": True}},
)

assert response.status_code == status.HTTP_403_FORBIDDEN
Expand Down Expand Up @@ -1611,6 +1613,15 @@ def test_create_target_records_the_signed_in_user_as_the_owner(self, client: Tes

assert mock_get_service.return_value.create_target_async.call_args.kwargs["owner"] == owner

@pytest.mark.parametrize("fields", [{}, {"register": True}, {"name": None}])
def test_create_target_needs_a_name_to_register_it(self, client: TestClient, fields: dict[str, object]) -> None:
with patch("pyrit.backend.routes.targets.get_target_service") as mock_get_service:
response = client.post("/api/targets", json={"type": "TextTarget", "params": {}, **fields})

assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT
assert "name is required when register=true" in json.dumps(response.json())
mock_get_service.return_value.create_target_async.assert_not_called()

def test_create_target_records_no_owner_when_not_saving(self, client: TestClient) -> None:
with (
patch("pyrit.backend.routes.targets.get_target_service") as mock_get_service,
Expand All @@ -1626,7 +1637,7 @@ def test_create_target_records_no_owner_when_not_saving(self, client: TestClient
@pytest.mark.parametrize(
("fields", "message"),
[
({}, "persist requires a name"),
({}, "name is required when register=true"),
({"name": "Contoso-GPT"}, "Invalid registry name"),
({"name": "contoso", "register": False}, "persist requires register=true"),
],
Expand Down Expand Up @@ -1663,7 +1674,7 @@ def test_create_target_passes_admin_flag_from_request(self, client: TestClient)
)
mock_get_service.return_value = mock_service

response = client.post("/api/targets", json={"type": "TextTarget", "params": {}})
response = client.post("/api/targets", json={"name": "text_target", "type": "TextTarget", "params": {}})

assert response.status_code == status.HTTP_201_CREATED
mock_has_admin.assert_called_once()
Expand Down
Loading
Loading