fix: filter HTTP client calls from Express route detection

This commit is contained in:
OpenClaw 2026-04-07 17:41:55 +05:30
parent 823454e1dc
commit f699ec92cf

View file

@ -1569,6 +1569,25 @@ const processFileGroup = (
const method = captureMap['express_route.method'].text;
const routePath = captureMap['express_route.path'].text;
if (EXPRESS_ROUTE_METHODS.has(method) && routePath.startsWith('/')) {
// Extract the receiver (the object the method is called on) to filter out
// HTTP client calls like axios.get('/api/users') that match the same pattern
// as Express route registrations.
const callNode = captureMap['express_route'];
const funcNode = callNode.childForFieldName?.('function') ?? callNode.children?.[0];
const receiverNode = funcNode?.childForFieldName?.('object') ?? funcNode?.children?.[0];
const receiverText = receiverNode?.text?.toLowerCase() ?? '';
// Known HTTP client receivers u2014 skip these, they're API consumers not routes
const HTTP_CLIENT_RECEIVERS = new Set([
'axios', 'request', 'fetch', 'http', 'https', 'got', 'ky',
'superagent', 'needle', 'undici', 'apiclient', 'client', 'httpclient',
]);
if (HTTP_CLIENT_RECEIVERS.has(receiverText)) {
// This is an HTTP client call, not a route definition u2014 skip it
continue;
}
const httpMethod =
method === 'all' || method === 'use' || method === 'route'
? 'GET'