Skip to content

fix(domain): fall back to unsuffixed API_URL in EnvConfig.apiUrl - #119

Merged
amaury901130 merged 1 commit into
mainfrom
fix/env-api-url-fallback
Sep 22, 2026
Merged

amaury901130 merged 1 commit into
mainfrom
fix/env-api-url-fallback

Conversation

@amaury901130

Copy link
Copy Markdown
Collaborator

Description

With the files as committed, the Dio base URL is always an empty string:

  • app/lib/main/init.dart loads env/.<ENV> (--dart-define ENV, default dev), which is env/.dev.
  • env/.dev defines API_URL=https://dummyjson.com (unsuffixed).
  • EnvConfig.apiUrl (modules/domain/lib/env/env_config.dart) only reads API_URL_$env, which is API_URL_DEV. That key isn't in the file, so it returns ''.

Fix: read API_URL_<FLAVOR> first and fall back to API_URL. This supports both layouts the template currently mixes:

  • one file per flavor (env/.dev) with API_URL;
  • a single file with suffixed keys, as documented in env/.env.example.

A suffixed key takes precedence, so existing projects that use the suffixed layout behave exactly as before. Adds modules/domain/test/env/env_config_test.dart, the first domain tests. modules/domain/test is already listed in sonar.tests.

Issue

known-issues #2 in #117 (partial).

Preview

N/A

Notes:

  • ⚠️ Not compiled or run locally, because no Flutter SDK was available where this was written. Please run cd modules/domain && flutter pub get && flutter test and melos analyze. The test relies on dotenv.testLoad from flutter_dotenv 5.x.
  • Intentionally out of scope (it needs a decision on which env layout the template standardizes on):
  • Doesn't conflict with chore: adopt FVM, migrate to Melos 7, upgrade dependencies #116.

🤖 Generated with Claude Code

EnvConfig.apiUrl only read API_URL_<FLAVOR>, but the committed per-flavor
file env/.dev (the one init.dart loads) defines plain API_URL, so the Dio
base URL was always empty. Read the suffixed key first and fall back to
API_URL, supporting both the per-flavor files and the single-file layout
of env/.env.example.

Adds the first domain unit tests (EnvConfig.apiUrl).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tarruk
tarruk self-requested a review September 22, 2026 19:54
@amaury901130
amaury901130 merged commit 5841ed2 into main Sep 22, 2026
@amaury901130
amaury901130 deleted the fix/env-api-url-fallback branch September 22, 2026 20:06
amaury901130 added a commit that referenced this pull request Sep 22, 2026
- known-issues: mark #1 and #5 resolved, narrow #2 to the remaining env
  layout drift, update #3/#13 for the new common and domain tests
- overview, CLAUDE.md, feature guide: drop the mapError warning, describe
  the API_URL fallback
- testing, bootstrap customization: current test dirs and sonar.tests

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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