Skip to content

Don't stay at one-step TAN '999' when the bank also allows a two-step method (#212) - #232

Open
gagam3hl wants to merge 1 commit into
raphaelm:masterfrom
gagam3hl:fix-3920-onestep-placeholder
Open

gagam3hl wants to merge 1 commit into
raphaelm:masterfrom
gagam3hl:fix-3920-onestep-placeholder

Conversation

@gagam3hl

@gagam3hl gagam3hl commented Nov 27, 2026 •

Copy link
Copy Markdown

Fixes #212.

Problem

fetch_tan_mechanisms() sets '999' as a placeholder before the sync dialog. Commerzbank (photoTAN) then answers:

3920 - Zugelassene Ein- und Zwei-Schritt-Verfahren für den Benutzer. (['900', '999'])

_process_response() only picks a two-step method if the current function is None or not in allowed_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 offers 900.
  • is_challenge_structured() fails with KeyError: '999', because '999' has no HITANS entry.

Change

  • client.py: when handling 3920, treat '999' like None, so the first supported two-step function (tan_process == '2') gets picked. If the bank only allows '999', the existing else branch 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:

  • 3920 with a two-step function plus '999' replaces the placeholder. This test fails without the fix.
  • 3920 with only '999' keeps '999'.
  • A two-step method the user chose explicitly is kept.

pytest tests: 72 passed. test_message_parser.py::test_robust_mode errors on master with or without this change.

Field experience

We use python-fints 5.0.1 in production against https://fints.commerzbank.de/fints and see exactly this 3920 response. So far we work around it by calling set_tan_mechanism() with the two-step function ourselves after fetch_tan_mechanisms() and before opening the dialog. Switching after dialog init, as described in the issue, can raise Cannot 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.

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Commerzbank photoTAN: current TAN mechanism remains 999 while 2-step mechanism is 900, similar issue with DKB and BW-Bank

1 participant