{"record":{"id":"f169c2058c4e4319","repo":"denoland/deno","slug":"err-ambiguous-argument","errorCode":"ERR_AMBIGUOUS_ARGUMENT","errorMessage":"The \"error/message\" argument is ambiguous. The error message \"${actual.message}\" is identical to the message.","messagePattern":"The \"error/message\" argument is ambiguous\\. The error message \"(.+?)\" is identical to the message\\.","errorType":"error_code","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/assert.ts","lineNumber":394,"sourceCode":"\nfunction expectsError(\n  stackStartFn,\n  actual,\n  error,\n  message,\n) {\n  if (typeof error === \"string\") {\n    if (arguments.length === 4) {\n      throw new ERR_INVALID_ARG_TYPE(\"error\", [\n        \"Object\",\n        \"Error\",\n        \"Function\",\n        \"RegExp\",\n      ], error);\n    }\n    if (typeof actual === \"object\" && actual !== null) {\n      if (actual.message === error) {\n        throw new ERR_AMBIGUOUS_ARGUMENT(\n          \"error/message\",\n          `The error message \"${actual.message}\" is identical to the message.`,\n        );\n      }\n    } else if (actual === error) {\n      throw new ERR_AMBIGUOUS_ARGUMENT(\n        \"error/message\",\n        `The error \"${actual}\" is identical to the message.`,\n      );\n    }\n    message = error;\n    error = undefined;\n  } else if (\n    error != null &&\n    typeof error !== \"object\" &&\n    typeof error !== \"function\"\n  ) {\n    throw new ERR_INVALID_ARG_TYPE(\"error\", [","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/node/polyfills/assert.ts#L376-L412","documentation":"Thrown when a string matcher is identical to the message of the caught error. A string matcher never matches anything (it only labels the failure message), so an identical value means the author almost certainly intended message matching; assert refuses with ERR_AMBIGUOUS_ARGUMENT to prevent a test that would silently assert nothing.","triggerScenarios":"The function throws new Error('boom') and the test calls assert.throws(fn, 'boom'); the same via assert.rejects(fn, 'boom') when the rejection has message 'boom'.","commonSituations":"Porting tests from frameworks where a string matcher performs matching; pasting the exact expected message text into the matcher slot.","solutions":["Use a RegExp matcher: assert.throws(fn, /^boom$/)","Use a constructor plus validation object: assert.throws(fn, { message: /^boom$/ })","Keep the string only if you truly want a failure label, and make its text differ from the error message"],"exampleFix":"// before\nassert.throws(fn, 'boom');\n// after\nassert.throws(fn, /^boom$/);","handlingStrategy":"validation","validationCode":"if (typeof matcher === 'string') matcher = new RegExp(`^${escapeRegExp(matcher)}$`);\nassert.throws(fn, matcher);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use RegExp for message matching; strings only label failures","Escape dynamic strings before embedding them in RegExp"],"tags":["assert","testing","ambiguity","node-compat"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}