Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync up with back end changes #7105

Merged
merged 6 commits into from
Dec 20, 2024
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
2 changes: 1 addition & 1 deletion frontend/app/src/components/bots/AutoBotBuilder.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
<ValidatingInput
autofocus
minlength={3}
maxlength={50}
maxlength={100}
invalid={errors.has("bot_principal")}
placeholder={i18nKey("bots.builder.principalPlaceholder")}
error={errors.get("bot_principal")}
Expand Down
14 changes: 7 additions & 7 deletions frontend/openchat-agent/src/services/candidService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { ReplicaNotUpToDateError, toCanisterResponseError } from "./error";
import { type Options, Packr } from "msgpackr";
import type { Static, TSchema } from "@sinclair/typebox";
import { Value } from "@sinclair/typebox/value";
import { AssertError, Value } from "@sinclair/typebox/value";

const MAX_RETRIES = process.env.NODE_ENV === "production" ? 7 : 3;
const RETRY_DELAY = 100;
Expand Down Expand Up @@ -242,11 +242,7 @@ export abstract class CandidService {
}

private static validate<T extends TSchema>(value: unknown, validator: T): Static<T> {
try {
return Value.Parse(validator, value);
} catch (err) {
throw new Error("Validation failed: " + JSON.stringify(err));
}
return Value.Parse(validator, value);
}

private static prepareMsgpackArgs<T extends TSchema>(
Expand All @@ -267,7 +263,11 @@ export abstract class CandidService {
const validated = CandidService.validate(response, validator);
return mapper(validated);
} catch (err) {
console.error("Validation failed for response: ", response);
console.error(
"Validation failed for response: ",
response,
err instanceof AssertError ? err.error : undefined,
);
throw err;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3415,8 +3415,8 @@ export function customParamFields(paramType: ApiSlashCommandParamType): SlashCom
} else if ("NumberParam" in paramType) {
return {
kind: "number",
minValue: paramType.NumberParam.min_length,
maxValue: paramType.NumberParam.max_length,
minValue: paramType.NumberParam.min_value,
maxValue: paramType.NumberParam.max_value,
choices: paramType.NumberParam.choices,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ export function apiAccessTokenType(domain: AccessTokenType): TAccessTokenType {
),
message_id: domain.messageId,
command_name: domain.commandName,
parameters: domain.parameters,
version: domain.version,
command_args: domain.parameters,
command_text: domain.commandText,
},
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/openchat-agent/src/services/userIndex/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@ export function apiCustomParamFields(param: SlashCommandParam): ApiSlashCommandP
case "number":
return {
NumberParam: {
min_length: param.minValue,
max_length: param.maxValue,
min_value: param.minValue,
max_value: param.maxValue,
choices: param.choices,
},
};
Expand Down
Loading
Loading