Repository navigation
fix(entries): limitar --to a 2031-12-31 e erros em JSON com --json - #68
Merged
Merged
Conversation
…--json
The API rejects end dates after 2031-12-31, so entries list/summary now
check --from/--to before any request. Every command wrapped by action()
reports errors on stderr as {"error": "..."} when --json is set,
leaving stdout empty and exiting 1.
Refs #65
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.
Refs #65
O que muda
entries listeentries summaryvalidam--from/--toantes de qualquer requisição. A data precisa serYYYY-MM-DDreal, e--tonão pode passar de2031-12-31, o limite da API ("A data limite de carregamento dos lançamentos é 31/12/2031"). O erro é claro:--to 2035-12-31 is past 2031-12-31, the last date Meu Dinheiro loads entries for. Use --to 2031-12-31 or earlier.--json: a correção é geral, emsrc/utils/action.ts. O wrapperaction()vê noCommandque o Commander passa como último argumento se--jsonestá ligado, e aíexitWithErrorescreve{"error": "<mensagem>"}no stderr. O stdout fica vazio e o exit code é 1. Sem--json, a saída continua como antes (✗ mensagemno stderr). Isso vale para validações (exitWithErrordireto) e para exceções (erro da API com status e corpo, por exemplo400 Bad Request - {"type":2,"error":"..."}) em todos os comandos embrulhados poraction().logger.errorusaconsole.error). O JSON "quebrado" relatado na issue era o texto do erro misturado à saída (por exemplo, com2>&1). Com--json, agora o stderr também é JSON válido.--json.Testes
test/entries-list-errors.test.ts(6 testes) cobre:--to> 2031 sem chamar a API (JSON exato no stderr, stdout vazio), o mesmo em texto nosummary,2031-12-31aceito (comfimconferido na query), data inválida, erro 400 da API virando JSON e a generalidade em outro comando (accounts list --jsoncom 500, e sem--jsono stderr não é JSON).GET /v2/lancamentos, que devolve os seeds por conta e data. Overify.shganha o helperexpect_json_error(falha, stdout vazio, stderr ={"error": ...}) e 4 passos E2E: list--jsonok,--to> 2031 em texto e em JSON, e erro 404 da API em--json.Verificação
scripts/verify.shlocal → VERIFICAÇÃO OK (133 testes, exit 0). Só mock, nada contra a API real.