{"record":{"id":"7ebc0ad12cb2ba01","repo":"Foundry376/Mailspring","slug":"onrequestcompletions-returned-an-invalid-type-it","errorCode":null,"errorMessage":"onRequestCompletions returned an invalid type. It must return an Array of tokens or a Promise that resolves to an array of tokens","messagePattern":"onRequestCompletions returned an invalid type\\. It must return an Array of tokens or a Promise that resolves to an array of tokens","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/components/tokenizing-text-field.tsx","lineNumber":865,"sourceCode":"  _refreshCompletions = (val = this.state.inputValue, { clear }: { clear?: boolean } = {}) => {\n    const usedKeys = this.props.tokens.map(this.props.tokenKey);\n    const removeUsedTokens = (tokens) => {\n      return tokens.filter((t) => !usedKeys.includes(this.props.tokenKey(t)));\n    };\n\n    const tokensOrPromise = this.props.onRequestCompletions(val, { clear });\n\n    if (_.isArray(tokensOrPromise)) {\n      this.setState({ completions: removeUsedTokens(tokensOrPromise) });\n    } else if (tokensOrPromise instanceof Promise) {\n      tokensOrPromise.then((tokens) => {\n        if (!this._mounted) {\n          return;\n        }\n        this.setState({ completions: removeUsedTokens(tokens) });\n      });\n    } else {\n      console.warn(\n        'onRequestCompletions returned an invalid type. It must return an Array of tokens or a Promise that resolves to an array of tokens'\n      );\n      this.setState({ completions: [] });\n    }\n  };\n\n  // Rendering\n\n  _completionsId() {\n    return `${this._inputId}-completions`;\n  }\n\n  _valueDescriptionId() {\n    return `${this._inputId}-value`;\n  }\n\n  _onActiveDescendantChange = (id: string | null) => {\n    this.setState({ activeDescendantId: id });","sourceCodeStart":847,"sourceCodeEnd":883,"githubUrl":"https://github.com/Foundry376/Mailspring/blob/648c685d602ece6bb00c22534b8734de6ac644b3/app/src/components/tokenizing-text-field.tsx#L847-L883","documentation":"Contract warning in TokenizingTextField._refreshCompletions: the onRequestCompletions prop returned neither an array nor a Promise (e.g. undefined or an object), so autocomplete completions cannot be populated and the completion dropdown stays empty/broken for that input.","triggerScenarios":"Thrown at app/src/components/tokenizing-text-field.tsx:865 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the consumer's onRequestCompletions to return an Array of tokens or a Promise resolving to one","Return an empty array instead of undefined when there are no completions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"648c685d602ece6bb00c22534b8734de6ac644b3","analyzedAt":"2026-09-03T02:00:24.311Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}