YMFE/yapi · error
This method name(${method}) is not exist.
Error message
This method name(${method}) is not exist. What it means
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.
Source
Thrown at common/power-string.js:181
}
function handleSegment(str, index) {
str = str.trim();
if (index === 0) {
return _handleValue(str);
}
let method,
args = [];
if (str.indexOf(methodAndArgsSeparateChar) > 0) {
str = str.split(methodAndArgsSeparateChar);
method = str[0].trim();
args = str[1].split(argsSeparateChar).map(item => _handleValue(item.trim()));
} else {
method = str;
}
if (typeof stringHandles[method] !== 'function') {
throw new Error(`This method name(${method}) is not exist.`);
}
return {
method,
args
};
}
module.exports = {
utils: stringHandles,
PowerString,
/**
* 类似于 angularJs的 filter 功能
* @params string
* @params fn 处理参数值函数,默认是一个返回原有参数值函数
*
* @expamle
* filter('string | substr: 1, 10 | md5 | concat: hello ')View on GitHub (pinned to 59bade3a8a)
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
Example fix
// before
const token = '${__hmacSha(unknown)'
// after
const token = '${__md5(password)}'; Defensive patterns
Strategy: validation
Validate before calling
const supported = ['md5','sha1','sha224','sha256','sha384','sha512','base64','unbase64','substr','concat','lconcat','lower','upper','length','number','sleep','split','join','quote','json','split'];
function assertMethod(name){ if (typeof supported.includes !== 'undefined' && !supported.includes(name)) throw new Error('unsupported power-string method: ' + name); } Type guard
function hasStringHandle(name){ try { const h = require('common/power-string.js'); return typeof h.stringHandles[name] === 'function'; } catch (e) { return false; } } Try / catch
try {
const val = yapi.commons.powerString('${__md5(v)}');
} catch (e) {
if (/method name/.test(e.message)) console.error('Fix the ${__method} name in your expression');
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Related errors
AI-assisted analysis of YMFE/yapi@59bade3a8a (2026-08-29).
Data as JSON: /api/errors/ecfdab27e3f2cba4.
Report an issue: GitHub.