MCPcopy Create free account
hub / github.com/callstack/agent-device / buildAmbiguousMatchError

Function buildAmbiguousMatchError

src/daemon/handlers/find.ts:631–651  ·  view source on GitHub ↗
(
  matches: SnapshotState['nodes'],
  locator: FindLocator,
  query: string,
)

Source from the content-addressed store, hash-verified

629}
630
631function buildAmbiguousMatchError(
632 matches: SnapshotState['nodes'],
633 locator: FindLocator,
634 query: string,
635): DaemonResponse {
636 const candidates = matches.slice(0, 8).map((candidate) => {
637 const label =
638 extractNodeText(candidate) || candidate.label || candidate.identifier || candidate.type || '';
639 return `@${candidate.ref}${label ? `(${label})` : ''}`;
640 });
641 return errorResponse(
642 'AMBIGUOUS_MATCH',
643 `find matched ${matches.length} elements for ${locator} "${query}". Use a more specific locator or selector.`,
644 {
645 locator,
646 query,
647 matches: matches.length,
648 candidates,
649 },
650 );
651}
652
653function shouldScopeFind(locator: FindLocator): boolean {
654 return locator !== 'role';

Callers 1

resolveFindMatchFunction · 0.85

Calls 2

extractNodeTextFunction · 0.90
errorResponseFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…