Skip to content

feat(server): optional default for get_setting_value#1669

Merged
jokob-sk merged 1 commit into
netalertx:mainfrom
Arvuno:feat/setting-value-default
Jun 3, 2026
Merged

feat(server): optional default for get_setting_value#1669
jokob-sk merged 1 commit into
netalertx:mainfrom
Arvuno:feat/setting-value-default

Conversation

@Arvuno
Copy link
Copy Markdown
Contributor

@Arvuno Arvuno commented Jun 3, 2026

Summary

  • Add an optional default parameter to get_setting_value in server/helper.py.
  • The parameter defaults to "" so every existing call site keeps its current behaviour.
  • New call sites can opt into a more meaningful fallback without growing the function's signature.

Why

get_setting_value currently returns "" for missing keys, which forces every caller to remember that "" is the sentinel and to provide its own fallback. The fallback is sometimes a hard-coded default and sometimes a different code path entirely, leading to inconsistent handling.

Adding an optional default is the minimum change that lets call sites clean up their own fallbacks without breaking any of the ~dozens of existing callers.

How tested

  • python -c "from helper import get_setting_value; print(get_setting_value('__nonexistent__'))"'' (unchanged)
  • python -c "from helper import get_setting_value; print(get_setting_value('__nonexistent__', default=42))"42 (new behaviour)
  • ruff/flake8 not installed in this environment; the diff is a 4-line signature/docstring change and is type-checked by the project's existing mypy CI.
  • No automated test added in this PR; the existing tests/ suite (if any) was not run because the project's test runner requires the full Docker stack. The change is verifiable by hand.

Notes

Summary by CodeRabbit

  • Enhancements
    • Improved settings retrieval to support customizable default values when configuration keys are not found, ensuring more predictable application behavior.

get_setting_value returns an empty string when a key is not found,
which forces every call site to remember to treat '' as a sentinel
and provide its own fallback. The fallback is sometimes a hard-coded
default and sometimes a different code path entirely, leading to
inconsistent handling across the codebase.

Add an optional  argument that defaults to '' (preserves
the existing behaviour for every call site) and is returned when
the key is not present. New call sites can opt into a more
meaningful default without changing the function's signature for
existing callers.

Refs netalertx#1626.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b79b2458-720c-457f-ba6d-e599de730e85

📥 Commits

Reviewing files that changed from the base of the PR and between 52defd2 and 6819f14.

📒 Files selected for processing (1)
  • server/helper.py

📝 Walkthrough

Walkthrough

The get_setting_value helper function in server/helper.py is enhanced to accept an optional default parameter with an empty-string fallback. When a setting key is missing, the function now returns the provided default value instead of always returning an empty string. The docstring is updated to document the new parameter and backwards-compatibility.

Changes

Setting Value Default Parameter

Layer / File(s) Summary
Add default parameter to get_setting_value
server/helper.py
Function signature now accepts an optional default parameter (defaulting to ""). Implementation uses the provided default when a setting key is missing. Docstring updated to document the new parameter and backwards-compatible behavior.

🐰 A setting seeks its way,

With defaults now to guide the day,

Where empty strings once filled the void,

Now custom values are deployed,

A helper's grace in every call!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding an optional default parameter to the get_setting_value function.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@jokob-sk jokob-sk merged commit 01d37fa into netalertx:main Jun 3, 2026
5 checks passed
@jokob-sk
Copy link
Copy Markdown
Collaborator

jokob-sk commented Jun 3, 2026

thanks for the PR @Arvuno

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.

2 participants