Compare commits

..

1 Commits

Author SHA1 Message Date
Owen
241610579c Show the input validation in the error report 2026-06-19 13:02:38 -04:00
4 changed files with 20 additions and 27 deletions

View File

@@ -48,18 +48,18 @@ export async function applyBlueprint({
name,
source = "API"
}: ApplyBlueprintArgs): Promise<Blueprint> {
// Validate the input data
const validationResult = ConfigSchema.safeParse(configData);
if (!validationResult.success) {
throw new Error(fromError(validationResult.error).toString());
}
const config: Config = validationResult.data;
let blueprintSucceeded: boolean = false;
let blueprintMessage: string;
let blueprintMessage = "";
let error: any | null = null;
try {
const validationResult = ConfigSchema.safeParse(configData);
if (!validationResult.success) {
throw new Error(fromError(validationResult.error).toString());
}
const config: Config = validationResult.data;
let proxyResourcesResults: PublicResourcesResults = [];
let clientResourcesResults: ClientResourcesResults = [];
await db.transaction(async (trx) => {

View File

@@ -40,7 +40,6 @@ type TargetRow = {
targetId: number;
resourceId: number;
siteId: number;
siteType: string | null;
siteName?: string;
mode: string | null;
ip: string;
@@ -106,8 +105,7 @@ function RdpServerForm({
const api = createApiClient(useEnvContext());
const router = useRouter();
const targets = targetsResponse.targets.filter((t) => t.mode === "rdp");
const browserGatewayTargets = targets.filter((t) => t.siteType === "newt");
const firstTarget = browserGatewayTargets[0];
const firstTarget = targets[0];
const formSchema = useMemo(
() => createBrowserGatewayTargetFormSchema(t),
@@ -117,7 +115,7 @@ function RdpServerForm({
const form = useForm<BrowserGatewayTargetFormValues>({
resolver: zodResolver(formSchema),
defaultValues: {
selectedSites: browserGatewayTargets.map((target) => ({
selectedSites: targets.map((target) => ({
siteId: target.siteId,
name: target.siteName ?? String(target.siteId),
type: "newt" as const

View File

@@ -62,7 +62,6 @@ type TargetRow = {
targetId: number;
resourceId: number;
siteId: number;
siteType: string | null;
siteName?: string;
mode: string | null;
ip: string;
@@ -131,9 +130,7 @@ function SshServerForm({
const isNativeInitially = resource.authDaemonMode === "native";
const targets = targetsResponse.targets.filter((t) => t.mode === "ssh");
const browserGatewayTargets = targets.filter((t) => t.siteType === "newt");
const firstTarget = targets[0];
const firstBrowserGatewayTarget = browserGatewayTargets[0];
const initialPamMode =
(resource.pamMode as "passthrough" | "push") || "passthrough";
const initialStandardDaemonLocation = isNativeInitially
@@ -166,18 +163,18 @@ function SshServerForm({
selectedSites:
isNativeInitially || useSingleSiteOnLoad
? []
: browserGatewayTargets.map((target) => ({
: targets.map((target) => ({
siteId: target.siteId,
name: target.siteName ?? String(target.siteId),
type: "newt" as const
})),
selectedSite:
useSingleSiteOnLoad && firstBrowserGatewayTarget
useSingleSiteOnLoad && firstTarget
? {
siteId: firstBrowserGatewayTarget.siteId,
siteId: firstTarget.siteId,
name:
firstBrowserGatewayTarget.siteName ??
String(firstBrowserGatewayTarget.siteId),
firstTarget.siteName ??
String(firstTarget.siteId),
type: "newt" as const
}
: null,
@@ -193,11 +190,11 @@ function SshServerForm({
: null,
destination: isNativeInitially
? ""
: (firstBrowserGatewayTarget?.ip ?? ""),
: (firstTarget?.ip ?? ""),
destinationPort: isNativeInitially
? "22"
: firstBrowserGatewayTarget
? String(firstBrowserGatewayTarget.port)
: firstTarget
? String(firstTarget.port)
: "22"
}
});

View File

@@ -40,7 +40,6 @@ type TargetRow = {
targetId: number;
resourceId: number;
siteId: number;
siteType: string | null;
siteName?: string;
mode: string | null;
ip: string;
@@ -106,8 +105,7 @@ function VncServerForm({
const api = createApiClient(useEnvContext());
const router = useRouter();
const targets = targetsResponse.targets.filter((t) => t.mode === "vnc");
const browserGatewayTargets = targets.filter((t) => t.siteType === "newt");
const firstTarget = browserGatewayTargets[0];
const firstTarget = targets[0];
const formSchema = useMemo(
() => createBrowserGatewayTargetFormSchema(t),
@@ -117,7 +115,7 @@ function VncServerForm({
const form = useForm<BrowserGatewayTargetFormValues>({
resolver: zodResolver(formSchema),
defaultValues: {
selectedSites: browserGatewayTargets.map((target) => ({
selectedSites: targets.map((target) => ({
siteId: target.siteId,
name: target.siteName ?? String(target.siteId),
type: "newt" as const