{"record":{"id":"ecfdab27e3f2cba4","repo":"YMFE/yapi","slug":"this-method-name-method-is-not-exist","errorCode":null,"errorMessage":"This method name(${method}) is not exist.","messagePattern":"This method name\\((.+?)\\) is not exist\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/power-string.js","lineNumber":181,"sourceCode":"}\n\nfunction handleSegment(str, index) {\n  str = str.trim();\n  if (index === 0) {\n    return _handleValue(str);\n  }\n\n  let method,\n    args = [];\n  if (str.indexOf(methodAndArgsSeparateChar) > 0) {\n    str = str.split(methodAndArgsSeparateChar);\n    method = str[0].trim();\n    args = str[1].split(argsSeparateChar).map(item => _handleValue(item.trim()));\n  } else {\n    method = str;\n  }\n  if (typeof stringHandles[method] !== 'function') {\n    throw new Error(`This method name(${method}) is not exist.`);\n  }\n\n  return {\n    method,\n    args\n  };\n}\n\nmodule.exports = {\n  utils: stringHandles,\n  PowerString,\n  /**\n   * 类似于 angularJs的 filter 功能\n   * @params string\n   * @params fn 处理参数值函数，默认是一个返回原有参数值函数\n   *\n   * @expamle\n   * filter('string | substr: 1, 10 | md5 | concat: hello ')","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/YMFE/yapi/blob/59bade3a8a43e7db077d38a4b0c7c584f30ddf8c/common/power-string.js#L163-L199","documentation":"power-string's handleSegment parses ${__method(args)} style expressions; if the method name before '(' is not a registered function in stringHandles, parsing throws this error.","triggerScenarios":"A field uses an expression like ${__myFunc(x)} where myFunc is not among built-in handlers (e.g. md5, base64, timestamp, unix) or a registered custom handler.","commonSituations":"Typo in function name; using Postman/other tool's functions ($guid, $randomInt) that YApi doesn't implement; custom script methods registered on server but not client (or vice versa).","solutions":["Correct the method name to one of the supported stringHandles functions","Register the custom method on the right side via a custom script (yapi-script) before using it","Verify the method exists on the environment where the expression is evaluated"],"exampleFix":"// before\nconst token = '${__hmacSha(unknown)'\n// after\nconst token = '${__md5(password)}';","handlingStrategy":"validation","validationCode":"const supported = ['md5','sha1','sha224','sha256','sha384','sha512','base64','unbase64','substr','concat','lconcat','lower','upper','length','number','sleep','split','join','quote','json','split'];\nfunction assertMethod(name){ if (typeof supported.includes !== 'undefined' && !supported.includes(name)) throw new Error('unsupported power-string method: ' + name); }","typeGuard":"function hasStringHandle(name){ try { const h = require('common/power-string.js'); return typeof h.stringHandles[name] === 'function'; } catch (e) { return false; } }","tryCatchPattern":"try {\n  const val = yapi.commons.powerString('${__md5(v)}');\n} catch (e) {\n  if (/method name/.test(e.message)) console.error('Fix the ${__method} name in your expression');\n  throw e;\n}","preventionTips":["Only use documented built-in string functions in ${__fn()} expressions","Register custom methods via yapi custom scripts before referencing them","Copy function names exactly (case-sensitive)","Test expressions in a simple case before broad use"],"tags":["expression-parsing","script","validation"],"backgroundTag":"unknown-function-name","analyzedSha":"59bade3a8a43e7db077d38a4b0c7c584f30ddf8c","analyzedAt":"2026-08-29T08:45:22.203Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}