Treat any data that originates outside your own trust boundary—upstream provider responses, client-supplied tool/parameter names, or unconfigured feature state—as potentially hostile, and default to the safest possible behavior rather than optimistically trusting or guessing it.
const shortMsg = stripHtmlTags(rawBody).slice(0, 200);
streamController.handleError({ message: shortMsg, status });
Protect reserved/internal identifiers from collision: before relying on a reserved name (e.g., an internally-injected tool name) to route trusted, privileged logic, check whether the client has already supplied a value with that same name. If so, abort the substitution instead of overwriting—otherwise client-controlled input can impersonate and execute as a trusted internal resource.
Apply this check during review: for any code path that takes external/unvalidated data and either (a) surfaces it to a user, (b) uses it to make a trust/identity decision, or (c) acts as a fallback when state is unset, confirm it sanitizes, validates for collisions, or fails closed rather than proceeding optimistically.