Foundry376/Mailspring · error
onRequestCompletions returned an invalid type. It must retur
Error message
onRequestCompletions returned an invalid type. It must return an Array of tokens or a Promise that resolves to an array of tokens
What it means
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.
Source
Thrown at app/src/components/tokenizing-text-field.tsx:865
_refreshCompletions = (val = this.state.inputValue, { clear }: { clear?: boolean } = {}) => {
const usedKeys = this.props.tokens.map(this.props.tokenKey);
const removeUsedTokens = (tokens) => {
return tokens.filter((t) => !usedKeys.includes(this.props.tokenKey(t)));
};
const tokensOrPromise = this.props.onRequestCompletions(val, { clear });
if (_.isArray(tokensOrPromise)) {
this.setState({ completions: removeUsedTokens(tokensOrPromise) });
} else if (tokensOrPromise instanceof Promise) {
tokensOrPromise.then((tokens) => {
if (!this._mounted) {
return;
}
this.setState({ completions: removeUsedTokens(tokens) });
});
} else {
console.warn(
'onRequestCompletions returned an invalid type. It must return an Array of tokens or a Promise that resolves to an array of tokens'
);
this.setState({ completions: [] });
}
};
// Rendering
_completionsId() {
return `${this._inputId}-completions`;
}
_valueDescriptionId() {
return `${this._inputId}-value`;
}
_onActiveDescendantChange = (id: string | null) => {
this.setState({ activeDescendantId: id });View on GitHub (pinned to 648c685d60)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at app/src/components/tokenizing-text-field.tsx:865 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Foundry376/Mailspring@648c685d60 (2026-09-03).
Data as JSON: /api/errors/7ebc0ad12cb2ba01.
Report an issue: GitHub.