fix(domain): fall back to unsuffixed API_URL in EnvConfig.apiUrl - #119
Merged
Merged
Conversation
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
self-requested a review
September 22, 2026 19:54
tarruk
approved these changes
Sep 22, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With the files as committed, the Dio base URL is always an empty string:
app/lib/main/init.dartloadsenv/.<ENV>(--dart-define ENV, defaultdev), which isenv/.dev.env/.devdefinesAPI_URL=https://dummyjson.com(unsuffixed).EnvConfig.apiUrl(modules/domain/lib/env/env_config.dart) only readsAPI_URL_$env, which isAPI_URL_DEV. That key isn't in the file, so it returns''.Fix: read
API_URL_<FLAVOR>first and fall back toAPI_URL. This supports both layouts the template currently mixes:env/.dev) withAPI_URL;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/testis already listed insonar.tests.Issue
known-issues #2 in #117 (partial).
Preview
N/A
Notes:
cd modules/domain && flutter pub get && flutter testandmelos analyze. The test relies ondotenv.testLoadfrom flutter_dotenv 5.x.FlavorConfig.getEnvFilePath()andEnvConfig.envConfigFile;.envinstructions in the doc comments;melos run:webusing the prod entrypoint (melos.yamlis being replaced in chore: adopt FVM, migrate to Melos 7, upgrade dependencies #116);app/env/is bundled into the binary.🤖 Generated with Claude Code