Repository navigation
fix(repl): aceita send --to/--template, rejeita flags desconhecidas - #4
Merged
Merged
Conversation
Bug: no REPL, comando como send --to +5511 --template welcome era parseado errado: - phone = "--to" (1o token vira phone) - templateName = "" (nunca lia --to ou --template) - freeformText = "+5511 --template welcome" (tudo cai no default) E o REPL mandava como mensagem de sessao (body livre) ao backend, que rejeitava com 422 "Nenhuma conversa iniciada com este número" porque processSessionMessage chama validateConversationWindow. Fix: - Detectar se primeiro token comeca com "-" (e flag, nao posicional) - Aceitar --to <phone> alem do posicional - Rejeitar flags desconhecidas em vez de tratar como freeform — evita mandar lixo pro backend em silencio - Aceitar --template e --vars (alem de -t e -v) — ja funcionava - Adicionar tests cobrindo as 3 sintaxes + edge cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
No REPL (TUI), digitar:
Falha com 422 do backend:
Causa
parseSendArgseminternal/tui/repl.go:Loop então:
+5511999cai nodefault→freeformText = "+5511999 --template welcome"--templateewelcomenunca são lidosResultado: REPL envia
{ receiver: "--to", body: "+5511999 --template welcome" }. Backend inferetype=text(tembody, não temtemplateName), rodaprocessSessionMessage→validateConversationWindow→ 422.Fix
parseSendArgsagora:--to <phone>além do posicional-t/--template(já aceitava ambos)-v/--varsrenderSendUsage()) — em vez de tratar silenciosamente como texto livreAdicionei
repl_send_args_test.gocom 7 casos cobrindo as 3 sintaxes + edge cases.Test plan
go test -race ./internal/tui/ -run TestParseSendArgs7/7 PASSgo test -race ./...todos verdesgolangci-lint run0 issuessend --to +5511 --template welcomeno REPL deve enviar como template (chega no backend) em vez de cair em 422🤖 Generated with Claude Code