Repository navigation
Conversation
…oo (raphaelm#212) fetch_tan_mechanisms() sets '999' as a placeholder before the sync dialog. When the bank answers 3920 with both a two-step function and '999' (Commerzbank photoTAN: ['900', '999']), _process_response() saw the placeholder as a valid choice and never selected the two-step method. minimal_interactive_cli_bootstrap() then treated '999' as already chosen, and is_challenge_structured() failed with KeyError: '999'. Treat '999' like None in both places. Banks that only allow '999' still fall back to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013em56AbgS1EJjr7jA7XaCe
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.
Fixes #212.
Problem
fetch_tan_mechanisms()sets'999'as a placeholder before the sync dialog. Commerzbank (photoTAN) then answers:_process_response()only picks a two-step method if the current function isNoneor not inallowed_security_functions. Because'999'is in the allowed list, the placeholder counts as a valid choice and the client stays at'999'. As a result:minimal_interactive_cli_bootstrap()treats'999'as already chosen and never offers900.is_challenge_structured()fails withKeyError: '999', because'999'has no HITANS entry.Change
client.py: when handling 3920, treat'999'likeNone, so the first supported two-step function (tan_process == '2') gets picked. If the bank only allows'999', the existingelsebranch still falls back to'999'.utils.py:minimal_interactive_cli_bootstrap()also treats'999'as "not chosen yet". This also repairs clients restored from saved state that already holds'999'. Trade-off: for banks that only offer one-step, the bootstrap now runs one extra sync dialog.Tests
There are three new tests in
tests/test_client.py:'999'replaces the placeholder. This test fails without the fix.'999'keeps'999'.pytest tests: 72 passed.test_message_parser.py::test_robust_modeerrors onmasterwith or without this change.Field experience
We use python-fints 5.0.1 in production against
https://fints.commerzbank.de/fintsand see exactly this 3920 response. So far we work around it by callingset_tan_mechanism()with the two-step function ourselves afterfetch_tan_mechanisms()and before opening the dialog. Switching after dialog init, as described in the issue, can raiseCannot change TAN mechanism with a standing dialog. With this patch the workaround is no longer needed. The patch itself has not been run against the live bank yet, only against the mock server.