{"record":{"id":"aad197b566711b4c","repo":"phacility/phabricator","slug":"value-for-number-argument-must-be-an-integer-or","errorCode":null,"errorMessage":"Value for \"number\" argument must be an integer or double, got %s.","messagePattern":"Value for \"number\" argument must be an integer or double, got (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/fact/chart/PhabricatorChartFunctionArgument.php","lineNumber":131,"sourceCode":"              'beginning with a function name as a string. The first list '.\n              'item has the wrong type, %s.',\n              phutil_describe_type($function_name)));\n        }\n\n        $functions = PhabricatorChartFunction::getAllFunctions();\n        if (!isset($functions[$function_name])) {\n          throw new Exception(\n            pht(\n              'Function \"%s\" is unknown. Valid functions are: %s',\n              $function_name,\n              implode(', ', array_keys($functions))));\n        }\n\n        return id(clone $functions[$function_name])\n          ->setArguments($value);\n      case 'number':\n        if (!is_float($value) && !is_int($value)) {\n          throw new Exception(\n            pht(\n              'Value for \"number\" argument must be an integer or double, '.\n              'got %s.',\n              phutil_describe_type($value)));\n        }\n\n        return $value;\n    }\n\n    throw new PhutilMethodNotImplementedException();\n  }\n\n}\n","sourceCodeStart":113,"sourceCodeEnd":145,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/fact/chart/PhabricatorChartFunctionArgument.php#L113-L145","documentation":"For 'number' typed chart function arguments, PhabricatorChartFunctionArgument::newValue() accepts only PHP int or float. Anything else — numeric strings, null, booleans — throws this Exception with the actual type from phutil_describe_type().","triggerScenarios":"Passing '7' (string) instead of 7, null from a missing key, or true/false as a number argument, e.g. array('constant', '100') from unvalidated request or JSON input.","commonSituations":"HTTP/Conduit request values arriving as strings and used unvalidated; JSON decoding configured to produce strings; idx() defaults of null flowing into argument lists; form inputs never cast.","solutions":["Cast to int/float before use: (int)$value or (float)$value when the source is a string parameter.","Validate with is_int($v) || is_float($v) during spec construction.","Reject null/boolean early at the request boundary.","Note there is no string coercion: strict typing is intentional."],"exampleFix":"// before\n$arguments[] = $request->getValue('limit'); // '100' (string) -> Exception\n\n// after\n$limit = $request->getValue('limit');\n$arguments[] = (int)$limit;","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function is_chart_number($value) {\n  return is_int($value) || is_float($value);\n}","tryCatchPattern":null,"preventionTips":["Cast string request parameters with (int)/(float) before use.","Note there is no coercion of numeric strings — strict int/float only.","Reject null and bool early when parsing external input."],"tags":["phabricator","facts","chart","argument-validation","type-error","php"],"backgroundTag":"invalid-argument-type","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}