-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Fix: prevent applyFormatting from crashing on string or undefined input #1659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ormatting-e-proteger-entrada Corrige erro em applyFormatting com valores não estruturados Esta correção adiciona verificação de tipo e valor falsy antes de aplicar o processamento de texto. Correção baseada em: EvolutionAPI#1624
Reviewer's GuideIntroduce early input validation in applyFormatting to safely handle string and falsy values, preventing runtime errors when processing simple or undefined message inputs. Class diagram for updated applyFormatting method in TypebotServiceclassDiagram
class TypebotService {
- applyFormatting(element: any): string
}
TypebotService : +applyFormatting(element)
%% The method now returns the element if it's a string, returns '' if falsy, otherwise processes as before.
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @JrStarkmidia - I've reviewed your changes - here's some feedback:
- Consider replacing the
any
type onelement
with a more specific union (e.g.string | RichTextNode | undefined
) so TypeScript can help catch invalid inputs at compile time. - You could simplify the guard clause by combining the falsy and string checks into a single condition (
if (!element || typeof element === 'string')
).
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider replacing the `any` type on `element` with a more specific union (e.g. `string | RichTextNode | undefined`) so TypeScript can help catch invalid inputs at compile time.
- You could simplify the guard clause by combining the falsy and string checks into a single condition (`if (!element || typeof element === 'string')`).
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…formatting Refactor applyFormatting type signature
Olá! Envio esta correção para evitar erros ao processar respostas do Typebot que são strings simples ou indefinidas. Sugestão aplicada conforme feedback automático do bot Sourcery. |
A sua correção não corrige o erro informado, que é |
Esse PR corrige o erro
Cannot read properties of undefined (reading 'applyFormatting')
que ocorre quando o Typebot envia mensagens simples em formato de string ou valores indefinidos.A função
applyFormatting
agora verifica se o valor é uma string ou falsy antes de tentar aplicar formatação. Isso evita que o sistema quebre ao tentar acessar.text
ou.children
de uma string.Correção útil para integração com Typebot, ChatGPT e outras automações que retornam texto direto.
Summary by Sourcery
Bug Fixes: