Address code review findings across relay, UI, and Go backend
- relay: key uploadables map by actual variable name instead of iteration index so order-mismatch between Object.keys passes can't desync the multipart map from form field names - mcp/v1: drop dead commented middleware line - DurationPicker: tighten parse regex to require PT prefix for M/H and P for D/W, and reject NaN in stringify so cleared inputs don't produce invalid duration strings Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -60,15 +60,16 @@ export const makeFetchQuery = (endpoint: string): FetchFunction => {
|
||||
const uploadableMap: {
|
||||
[key: string]: string[];
|
||||
} = {};
|
||||
const uploadableKeys = Object.keys(uploadables);
|
||||
|
||||
Object.keys(uploadables).forEach((key, index) => {
|
||||
uploadableMap[index] = [`variables.${key}`];
|
||||
uploadableKeys.forEach((key) => {
|
||||
uploadableMap[key] = [`variables.${key}`];
|
||||
});
|
||||
|
||||
formData.append("map", JSON.stringify(uploadableMap));
|
||||
|
||||
Object.keys(uploadables).forEach((key, index) => {
|
||||
formData.append(index.toString(), uploadables[key]);
|
||||
uploadableKeys.forEach((key) => {
|
||||
formData.append(key, uploadables[key]);
|
||||
});
|
||||
|
||||
requestInit.body = formData;
|
||||
|
||||
@@ -26,7 +26,7 @@ type Props = {
|
||||
} & HTMLAttributes<HTMLInputElement>;
|
||||
|
||||
const stringify = (value: number | null, unit: string): string | null => {
|
||||
if (value === null || value <= 0) return null;
|
||||
if (value === null || !Number.isFinite(value) || value <= 0) return null;
|
||||
|
||||
switch (unit) {
|
||||
case "M":
|
||||
@@ -43,10 +43,10 @@ const stringify = (value: number | null, unit: string): string | null => {
|
||||
};
|
||||
|
||||
const parse = (value: string): { amount: number; unit: string } => {
|
||||
const match = value.match(/PT?(\d+)([MDWH])/);
|
||||
const match = value.match(/^P(?:T(\d+)([MH])|(\d+)([DW]))$/);
|
||||
if (!match) return { amount: 0, unit: "D" };
|
||||
const amount = parseInt(match[1], 10) || 0;
|
||||
const unit = match[2];
|
||||
const amount = parseInt(match[1] ?? match[3] ?? "0", 10) || 0;
|
||||
const unit = match[2] ?? match[4] ?? "D";
|
||||
if (amount % 7 === 0 && unit === "D") {
|
||||
return { amount: amount / 7, unit: "W" };
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ func NewMux(logger *log.Logger, proboSvc *probo.Service, iamSvc *iam.Service, ac
|
||||
logger = logger.Named("mcp.v1")
|
||||
|
||||
logger.Info("initializing MCP server")
|
||||
// server.AddReceivingMiddleware(mcputils.LoggingMiddleware(logger))
|
||||
|
||||
resolver := &Resolver{
|
||||
proboSvc: proboSvc,
|
||||
|
||||
Reference in New Issue
Block a user