{"record":{"id":"bcdf53d530db73d1","repo":"qeeqbox/social-analyzer","slug":"info-original-error-br-try-this-info-co","errorCode":null,"errorMessage":"info.original + ' [Error]<br>Try this: ' + info.corrected","messagePattern":"info\\.original \\+ ' \\[Error\\]<br>Try this: ' \\+ info\\.corrected","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"info","filePath":"modules/external-apis.js","lineNumber":91,"sourceCode":"        info.original = response.data.queries.request[0].searchTerms\n      } catch (e) {}\n      try {\n        info.corrected = response.data.spelling.correctedQuery\n      } catch (e) {}\n      try {\n        info.total = response.data.searchInformation.totalResults\n      } catch (e) {}\n      try {\n        response.data.items.forEach(function (item) {\n          info.items.push({\n            title: item.title,\n            snippet: item.snippet\n          })\n        })\n      } catch (e) {}\n      try {\n        if (info.total === 0 && info.corrected !== '') {\n          info.checking = info.original + ' [Error]<br>Try this: ' + info.corrected\n        } else if (info.total > 0 && info.corrected !== '') {\n          info.checking = info.original + ' [Good]<br>Suggested word: ' + info.corrected + '<br>Total lookups: ' + info.total\n        } else if (info.total > 0 && info.corrected === '') {\n          info.checking = info.original + ' [Good]<br>Total lookups: ' + info.total\n        } else {\n          info.checking = 'Using ' + info.original + ' with no lookups'\n        }\n      } catch (e) {}\n    }\n  } catch (error) {\n    helper.verbose && console.log(error)\n  }\n}\n\nasync function custom_search_ouputs (req) {\n  const possible_parameters = ['user', 'profile', 'account']\n  const time = new Date()\n  const functions = []","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/qeeqbox/social-analyzer/blob/1ba0905e00d054aab833eb3693739c354db09e0f/modules/external-apis.js#L73-L109","documentation":"In check_engines (modules/external-apis.js:91) info.checking is assigned a message string, not an Error thrown by the library. The message `info.original + ' [Error]<br>Try this: ' + info.corrected` is built when the Google Custom Search JSON API returns zero total results but includes a spelling correction (spelling.correctedQuery). It signals the searched term yielded no hits and Google suggests an alternative spelling.","triggerScenarios":"Calling check_engines (via custom_search flows) where helper.get_url_wrapper_json against googleapis.com/customsearch/v1 succeeds but the response has searchInformation.totalResults === 0 and a non-empty spelling.correctedQuery — i.e. a misspelled or no-result query when google_api_key and google_api_cs are configured.","commonSituations":"Developers searching username strings with special characters that Google treats as misspellings; quota-exhausted or malformed API responses parsing to empty fields so info.total stays 0/undefined; wrong CX (custom search engine id) scoped to no sites, returning 0 results with odd suggestions.","solutions":["Check info.checking for the '[Error]' marker and retry with the suggested word parsed after 'Try this: ',' or use info.corrected directly as the corrected query","Validate that Google API key and CX are valid and the CSE is configured to search the whole web, so totalResults is meaningful","Treat totalResults as a string/number defensively (it is a string in the API; '0' vs 0 comparisons can misbranch)","If lookups always show 0, verify quota (100 free queries/day) and that responses are not empty due to get_url_wrapper_json failures"],"exampleFix":"// before\nconsole.log(info.checking) // 'johnn [Error]<br>Try this: johnny'\n// after\nif (info.checking && info.checking.includes('[Error]')) {\n  const suggestion = info.corrected\n  // re-run the search with `suggestion` instead of info.original\n}","handlingStrategy":"try-catch","validationCode":"if (helper.google_api_key === '' || helper.google_api_cs === '') {\n  // skip engine check entirely, as check_engines itself does\n}\nif (!info || typeof info !== 'object') throw new TypeError('info object required')","typeGuard":"function hasNoResultsWithSuggestion(info) {\n  return info && Number(info.total) === 0 && typeof info.corrected === 'string' && info.corrected !== ''\n}","tryCatchPattern":"try {\n  await check_engines(req, info)\n  if (typeof info.checking === 'string' && info.checking.includes('[Error]')) {\n    // no results: retry with info.corrected as the query\n  }\n} catch (e) {\n  // API/transport failure: degrade gracefully, keep info.checking undefined\n}","preventionTips":["Validate info fields (total, corrected, original) are set before reading info.checking","Coerce searchInformation.totalResults with Number() — the API returns it as a string","Check Google API quota and key/CX validity so results are not silently empty","Guard for missing response.data.queries/spelling paths before dereferencing"],"tags":["google-api","custom-search","spelling","no-results"],"backgroundTag":"google-custom-search-no-results","analyzedSha":"1ba0905e00d054aab833eb3693739c354db09e0f","analyzedAt":"2026-08-31T21:42:26.566Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}