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:
Sacha Al Himdani
2026-05-12 14:34:49 +02:00
parent 85c028b537
commit fc24306cd8
3 changed files with 9 additions and 9 deletions

View File

@@ -60,15 +60,16 @@ export const makeFetchQuery = (endpoint: string): FetchFunction => {
const uploadableMap: { const uploadableMap: {
[key: string]: string[]; [key: string]: string[];
} = {}; } = {};
const uploadableKeys = Object.keys(uploadables);
Object.keys(uploadables).forEach((key, index) => { uploadableKeys.forEach((key) => {
uploadableMap[index] = [`variables.${key}`]; uploadableMap[key] = [`variables.${key}`];
}); });
formData.append("map", JSON.stringify(uploadableMap)); formData.append("map", JSON.stringify(uploadableMap));
Object.keys(uploadables).forEach((key, index) => { uploadableKeys.forEach((key) => {
formData.append(index.toString(), uploadables[key]); formData.append(key, uploadables[key]);
}); });
requestInit.body = formData; requestInit.body = formData;

View File

@@ -26,7 +26,7 @@ type Props = {
} & HTMLAttributes<HTMLInputElement>; } & HTMLAttributes<HTMLInputElement>;
const stringify = (value: number | null, unit: string): string | null => { 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) { switch (unit) {
case "M": case "M":
@@ -43,10 +43,10 @@ const stringify = (value: number | null, unit: string): string | null => {
}; };
const parse = (value: string): { amount: number; unit: string } => { 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" }; if (!match) return { amount: 0, unit: "D" };
const amount = parseInt(match[1], 10) || 0; const amount = parseInt(match[1] ?? match[3] ?? "0", 10) || 0;
const unit = match[2]; const unit = match[2] ?? match[4] ?? "D";
if (amount % 7 === 0 && unit === "D") { if (amount % 7 === 0 && unit === "D") {
return { amount: amount / 7, unit: "W" }; return { amount: amount / 7, unit: "W" };
} }

View File

@@ -40,7 +40,6 @@ func NewMux(logger *log.Logger, proboSvc *probo.Service, iamSvc *iam.Service, ac
logger = logger.Named("mcp.v1") logger = logger.Named("mcp.v1")
logger.Info("initializing MCP server") logger.Info("initializing MCP server")
// server.AddReceivingMiddleware(mcputils.LoggingMiddleware(logger))
resolver := &Resolver{ resolver := &Resolver{
proboSvc: proboSvc, proboSvc: proboSvc,