When inputs/settings are optional (undefined/nullable) treat null/undefined as part of the product logic: distinguish “absent” from “explicit empty”, prefer explicit reset values, and gate behavior so missing context can’t silently pick the wrong fallback or misclassify errors.
Practical rules:
??/length checks; don’t treat [] the same as “not provided”.// If the caller omits images, keep retry’s images.
const effectiveImages = images?.length ? images : retry.images
await initTask(retry.prompt, effectiveImages, files)
null/cleared auth fields) through the correct contract so old values can’t win by precedence.// Only override when caller actually supplied a key.
const apiKey = typeof args?.api_key === 'string' ? args.api_key : undefined
if (apiKey?.trim() && update.auth === undefined) {
update.auth = { accessToken: "", refreshToken: "" } // explicit clear/reset intent
}
const canSendCloud =
cloudSessionsEnabled && cloudTaskTarget?.target === "cloud" && !!cloudTaskTarget.repoUrl
if (!canSendCloud) return // or disable send until repoUrl exists
Checklist for PRs:
?./??/nullable field, write down the intended semantics: absent vs empty vs reset.