Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/api/wizard.zig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub const ProviderProbeResult = struct {
// ─── Path Parsing ────────────────────────────────────────────────────────────

/// Extract the component name from a wizard API path.
/// Matches `/api/wizard/{component}` or `/api/wizard/{component}/models`.
/// Matches `/api/wizard/{component}` and supported wizard subroutes.
/// Returns null if the path doesn't match the expected prefix or is empty.
pub fn extractComponentName(target: []const u8) ?[]const u8 {
const prefix = "/api/wizard/";
Expand Down Expand Up @@ -79,7 +79,7 @@ pub fn extractComponentName(target: []const u8) ?[]const u8 {
return rest;
}

/// Check if a target path matches `/api/wizard/{component}` or `/api/wizard/{component}/models`.
/// Check if a target path matches `/api/wizard/{component}` or a supported wizard subroute.
pub fn isWizardPath(target: []const u8) bool {
return extractComponentName(target) != null;
}
Expand Down
22 changes: 21 additions & 1 deletion src/integration_tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,17 @@ test "integration harness covers wizard failure contracts" {
try std.testing.expect(std.mem.indexOf(u8, resp.body, "invalid JSON body") != null);
}

{
const resp = try server.fetch(.{
.path = "/api/wizard/nullclaw/models",
.method = .POST,
.body = "{\"provider\":\"\"}",
});
defer resp.deinit(std.testing.allocator);
try std.testing.expectEqual(std.http.Status.bad_request, resp.status);
try std.testing.expect(std.mem.indexOf(u8, resp.body, "provider is required") != null);
}

{
const resp = try server.fetch(.{
.path = "/api/wizard/missing-component/models",
Expand All @@ -666,6 +677,15 @@ test "integration harness covers wizard failure contracts" {
});
defer resp.deinit(std.testing.allocator);
try std.testing.expectEqual(std.http.Status.not_found, resp.status);
try std.testing.expect(std.mem.indexOf(u8, resp.body, "component not found") != null);
try std.testing.expect(std.mem.indexOf(u8, resp.body, "component not found or models unavailable") != null);
}

{
const resp = try server.fetch(.{
.path = "/api/wizard/missing-component/models?provider=openai",
});
defer resp.deinit(std.testing.allocator);
try std.testing.expectEqual(std.http.Status.not_found, resp.status);
try std.testing.expect(std.mem.indexOf(u8, resp.body, "component not found or models unavailable") != null);
}
}
Loading