{"record":{"id":"4783b861df719061","repo":"squidfunk/mkdocs-material","slug":"invalid-query-query-see-https-bit-ly-2s3ch","errorCode":null,"errorMessage":"Invalid query: ${query} – see https://bit.ly/2s3ChXG","messagePattern":"Invalid query: (.+?) – see https://bit\\.ly/2s3ChXG","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/templates/assets/javascripts/integrations/search/worker/main/index.ts","lineNumber":168,"sourceCode":"    case SearchMessageType.SETUP:\n      await setupSearchLanguages(message.data.config)\n      index = new Search(message.data)\n      return {\n        type: SearchMessageType.READY\n      }\n\n    /* Search query message */\n    case SearchMessageType.QUERY:\n      const query = message.data\n      try {\n        return {\n          type: SearchMessageType.RESULT,\n          data: index.search(query)\n        }\n\n      /* Return empty result in case of error */\n      } catch (err) {\n        console.warn(`Invalid query: ${query} – see https://bit.ly/2s3ChXG`)\n        console.warn(err)\n        return {\n          type: SearchMessageType.RESULT,\n          data: { items: [] }\n        }\n      }\n\n    /* All other messages */\n    default:\n      throw new TypeError(\"Invalid message type\")\n  }\n}\n\n/* ----------------------------------------------------------------------------\n * Worker\n * ------------------------------------------------------------------------- */\n\n/* Expose Lunr.js in global scope, or stemmers won't work */","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/squidfunk/mkdocs-material/blob/e2136532f40aed98af1f6497c0cc6a3cff9f759b/src/templates/assets/javascripts/integrations/search/worker/main/index.ts#L150-L186","documentation":"The Material for MkDocs built-in search integration's web worker calls index.search(query) inside a try/catch. If the query makes lunr throw (e.g. a lone wildcard or unbalanced syntax), the handler logs 'Invalid query: <query> – see https://bit.ly/2s3ChXG' plus the error to the console and returns an empty result set instead of crashing the worker. It is a console warning, not an exception surfaced to the user.","triggerScenarios":"A user types a query that lunr cannot parse — commonly a bare '*' wildcard with no term (e.g. searching just '*'), unbalanced quotes, or other lunr query syntax it rejects in the pipeline function.","commonSituations":"Users pasting '*' or '?:' style patterns into the documentation search box; queries with stray quotes or special lunr field syntax; localized input where a lone wildcard is used as a 'show everything' shortcut.","solutions":["Enter a query with at least one term before any wildcard, e.g. 'inst*' instead of '*'","Remove or balance quote characters and special lunr operators in the query","Note that results are intentionally empty here — fix the query rather than the site configuration","If legitimate queries keep failing, check the lunr version bundled with the theme and update Material for MkDocs","If a custom search pipeline/extension is installed, verify it handles edge-case tokens"],"exampleFix":"// before (browser search input)\nsearch: \"*\"\n// after\nsearch: \"mkdocs*\"","handlingStrategy":"fallback","validationCode":"// in the search UI before posting to the worker\nfunction isValidQuery(query: string): boolean {\n  const trimmed = query.trim()\n  return trimmed.length > 0 && !/^\\*+$/.test(trimmed)\n}\nif (!isValidQuery(query)) return // skip search for wildcard-only queries","typeGuard":"function isSearchable(query: string): boolean {\n  return query.trim().length > 0 && query.trim() !== \"*\"\n}","tryCatchPattern":"// the worker already falls back gracefully; mirror it on the caller side\nworker.addEventListener(\"message\", (ev) => {\n  if (ev.data.type === SearchMessageType.RESULT && ev.data.data.items.length === 0) {\n    console.warn(`Empty results — query may be invalid: ${lastQuery}`)\n  }\n})","preventionTips":["Require at least one term before a wildcard in the search box","Strip or escape unbalanced quotes and lunr special characters from user input","Show a hint in the UI when a search returns empty items","Keep Material for MkDocs updated so bundled lunr fixes are included","Treat this as a console warning only — the worker already recovers with empty results"],"tags":["typescript","search","lunr","web-worker"],"backgroundTag":"invalid-search-query","analyzedSha":"e2136532f40aed98af1f6497c0cc6a3cff9f759b","analyzedAt":"2026-08-29T11:20:04.299Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}