Skip to content

Fix API_key message showing the API port instead of the access key - #1867

Merged
securestep9 merged 3 commits into
OWASP:masterfrom
Dio77799:fix/api-key-placeholder-locales
Nov 12, 2026
Merged

securestep9 merged 3 commits into
OWASP:masterfrom
Dio77799:fix/api-key-placeholder-locales

Conversation

@Dio77799

Copy link
Copy Markdown
Contributor

Proposed change

Fixes #1861

nettacker/api/engine.py formats the startup banner as
_("API_key").format(options.api_port, options.api_access_key). 20 locales only had {0},
so they printed the port where the access key should be. This changes {0} to {1} in those
strings (no translation text changes) and adds a regression test that renders API_key for
every locale and checks that the key is in the output.

The PR for #1860 (#1866) only adds missing Spanish keys and does not touch API_key, so both
can be merged in any order.

Tests: the new test passes for all 24 locales; with the locale change reverted, 20 cases fail.

Type of change

  • New core framework functionality
  • Bugfix (non-breaking change that fixes an issue)
  • Code refactoring without any functionality changes
  • New or existing module/payload change
  • Documentation/localization improvement
  • Test coverage improvement
  • Dependency upgrade
  • Other improvement (best practice, cleanup, optimization, etc)

Checklist

  • I've followed the contributing guidelines
  • I've digitally signed all my commits in this PR
  • I've run make pre-commit and confirm it didn't generate any warnings/changes
  • I've run make test and I confirm all tests passed locally
  • I've added/updated any relevant documentation in the docs/ folder
  • I've linked this PR with an open issue
  • I've tested and verified that my code works as intended and resolves the issue as described
  • I've attached screenshots demonstrating that my code works as intended (if applicable)
  • I've checked all other open PRs to avoid submitting duplicate work
  • I confirm that the code and comments in this PR are not direct unreviewed outputs of AI
  • I confirm that I am the Sole Responsible Author for every line of code, comment, and design decision

nettacker/api/engine.py formats API_key as (api_port, api_access_key),
but 20 locales only had a {0} placeholder, so the startup banner printed
the port where the API key should be. Use {1} for the key, matching
en.yaml, and add a regression test that renders API_key for every locale.

Fixes OWASP#1861
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bd56281 and 1d4cf8d.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected API key formatting across supported translations, ensuring the key appears properly in localized messages.
  • Tests
    • Added coverage to verify API key messages render correctly across locales.

Walkthrough

Twenty locale files now use {1} for the API access key in the API_key message. A unit test formats available locale messages and checks that the rendered output contains the test access key.

Changes

API key locale messages

Layer / File(s) Summary
Locale placeholders and rendered-key test
nettacker/locale/{ar,de,el,es,fa,fr,hy,id,it,iw,ja,ko,nl,ps,pt-br,ru,tr,ur,vi,zh-cn}.yaml, tests/unit/core/test_locale_messages.py
The 20 locale messages use {1} instead of {0}. The test formats each available API_key message and checks that its output contains the test access key.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • OWASP/Nettacker#1860 — The PR changes the Spanish API_key placeholder, but does not add the other missing Spanish translations requested by the issue.

Possibly related PRs

  • OWASP/Nettacker#1866 — This PR also changes nettacker/locale/es.yaml, and its description notes that the API_key placeholder is handled by this change.
Merge Risk: Minimal · previous review ddedd

The API key message in 20 languages will now show the access key instead of the port. The change is small and low risk, and it adds test coverage.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: the API_key banner showed the API port where the access key should appear. The changeset changes the {0} placeholder to {1} in 20 locale files, which matches this tit…
Description check Passed The description explains the cause (engine.py passes port and access key as format arguments, while 20 locales only had {0}), the fix (changing {0} to {1} with no translation text changes), and the re…
Linked Issues check Passed Issue #1861 requires two coding changes: (1) change {0} to {1} in the 20 listed locale API_key strings, and (2) add a unit test that renders API_key for every locale and checks that the access…
Out of Scope Changes check Passed The PR changes only the 20 locale API_key strings and adds one test file. Each locale change replaces {0} with {1} and does not alter translation text, which the issue specifies. The test file d…
Full details: Title check

Explanation

The title states the main change: the API_key banner showed the API port where the access key should appear. The changeset changes the {0} placeholder to {1} in 20 locale files, which matches this title. A regression test is also added, which the title does not mention, but that is expected.

Full details: Description check

Explanation

The description explains the cause (engine.py passes port and access key as format arguments, while 20 locales only had {0}), the fix (changing {0} to {1} with no translation text changes), and the regression test. It also links issue #1861 and notes test results. It is directly related to the changeset.

Full details: Linked Issues check

Explanation

Issue #1861 requires two coding changes: (1) change {0} to {1} in the 20 listed locale API_key strings, and (2) add a unit test that renders API_key for every locale and checks that the access key appears. The PR changes the placeholder in the 20 locale files, as listed in the summary. I confirmed this in nettacker/locale/de.yaml: API_key: "* API-Schlüssel: {1}" (was {0}), with no translation text change. The PR adds tests/unit/core/test_locale_messages.py, which parametrizes over all *.yaml locale files, skips files without API_key, formats the message with (5000, "test-access-key-1234"), and asserts the key appears in the output. This matches the issue's test requirement. Because the test formats with two arguments, a locale that still uses only {0} would print the port, not the key, and the test would fail. I did not inspect the diff of all 20 locale files individually; the remaining locale changes rest on the summary and the author's reported test results (20 failures when reverted).

Full details: Out of Scope Changes check

Explanation

The PR changes only the 20 locale API_key strings and adds one test file. Each locale change replaces {0} with {1} and does not alter translation text, which the issue specifies. The test file directly verifies the issue's requirement. No unrelated functional change appears in the reviewed summary or in the inspected de.yaml and test diffs.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c7ecc2c and ddedd0a.

Files selected for processing: 21

  • nettacker/locale/ar.yaml
  • nettacker/locale/de.yaml
  • nettacker/locale/el.yaml
  • nettacker/locale/es.yaml
  • nettacker/locale/fa.yaml
  • nettacker/locale/fr.yaml
  • nettacker/locale/hy.yaml
  • nettacker/locale/id.yaml
  • nettacker/locale/it.yaml
  • nettacker/locale/iw.yaml
  • nettacker/locale/ja.yaml
  • nettacker/locale/ko.yaml
  • nettacker/locale/nl.yaml
  • nettacker/locale/ps.yaml
  • nettacker/locale/pt-br.yaml
  • nettacker/locale/ru.yaml
  • nettacker/locale/tr.yaml
  • nettacker/locale/ur.yaml
  • nettacker/locale/vi.yaml
  • nettacker/locale/zh-cn.yaml
  • tests/unit/core/test_locale_messages.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@securestep9

Copy link
Copy Markdown
Collaborator

Thank you for your contribution @Dio77799 ! 🚀

@securestep9
securestep9 added this pull request to the merge queue Nov 12, 2026
Merged via the queue into OWASP:master with commit 49e2e84 Nov 12, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API_key startup message shows the API port instead of the access key in 20 locales

2 participants