Skip to content

fix: support REPOWISE_PORT env var in serve command#455

Merged
RaghavChamadiya merged 1 commit into
repowise-dev:mainfrom
muhamedfazalps:fix/serve-port-envvar
Jun 12, 2026
Merged

fix: support REPOWISE_PORT env var in serve command#455
RaghavChamadiya merged 1 commit into
repowise-dev:mainfrom
muhamedfazalps:fix/serve-port-envvar

Conversation

@muhamedfazalps

Copy link
Copy Markdown
Contributor

Problem

Fixes #427 — Setting REPOWISE_PORT in your .env file (as documented in .env.example) has no effect. The repowise serve command always starts on the default port 7337 because the --port click option doesn't read from the REPOWISE_PORT environment variable.

Root Cause

At /packages/cli/src/repowise/cli/commands/serve_cmd.py:481, the --port option was defined as:

@click.option("--port", default=7337, type=int, help="API server port.")

Click supports reading from environment variables natively via envvar=, but it wasn't wired up. So even when REPOWISE_PORT=7000 is set in .env and loaded by load_dotenv(), the option always used its hardcoded default of 7337.

Fix

Added envvar="REPOWISE_PORT" to the click option:

@click.option("--port", default=7337, type=int, help="API server port.", envvar="REPOWISE_PORT")

Now:

  1. REPOWISE_PORT is read from the environment (set via .env or export)
  2. --port CLI flag still takes precedence over the env var
  3. Falls back to 7337 if neither is provided

Testing

  • Set REPOWISE_PORT=7000 in .env, run repowise serve → API starts on 7000
  • Run repowise serve --port 8000 → CLI flag overrides env var
  • Run repowise serve without env var → starts on 7337

If this fix helped, consider buying me a coffee! ☕
Buy Me A Coffee

The serve_command click option for --port did not read the
REPOWISE_PORT environment variable. Users who set REPOWISE_PORT
in their .env file (as documented in .env.example) would find
that the server always started on the default port 7337.

Add envvar="REPOWISE_PORT" so click resolves the port from
the environment when the --port flag is not given.

Fixes repowise-dev#427
@repowise-bot

repowise-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

✅ Health: 7.7 (unchanged)
1 hotspot · 5 hidden couplings · 1 with fix history

🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)

🧪 No test files were touched in this PR — consider adding coverage for the files above.

🔥 Hotspot touched (1)
  • .../commands/serve_cmd.py — 16 commits/90d, 1 dependents · primary owner: Raghav Chamadiya (72%)
🔗 Hidden coupling (1 file)
  • .../commands/serve_cmd.py co-changes with these files (not in this PR):
    • .../cli/helpers.py (4× — 🟢 routine)
    • pyproject.toml (4× — 🟢 routine)
    • .../server/provider_config.py (3× — 🟢 routine)
    • .../server/app.py (3× — 🟢 routine)
    • .../persistence/database.py (3× — 🟢 routine)

📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-06-11 13:10 UTC
Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot

@RaghavChamadiya RaghavChamadiya merged commit 07a103e into repowise-dev:main Jun 12, 2026
5 checks passed
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.

[Bug] Setting custom API port does not work in repowise serve

2 participants