Skip to content

[Devportal] Support repeatable --config flag - #3002

Merged
lasanthaS merged 2 commits into
wso2:mainfrom
Piumal1999:config-param
Jul 30, 2026
Merged

[Devportal] Support repeatable --config flag#3002
lasanthaS merged 2 commits into
wso2:mainfrom
Piumal1999:config-param

Conversation

@Piumal1999

@Piumal1999 Piumal1999 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Purpose

Fix #2876

Summary

  • The portal used to read config from one fixed path, configs/config.toml. The path is now given explicitly: --config .
  • --config can be passed several times. Files stack in order, later ones winning per key — so one shared base file plus a small per-environment overlay, instead of a full copy per environment. (Nested tables merge; a list in an overlay replaces the base list, it doesn't append.)
  • The flag is required. Before, a missing config file meant the portal quietly started on built-in defaults — bad, since that file holds session secrets, encryption keys, and IdP settings. Now no config (or missing / bad TOML / no [developer_portal] table) prints why and exits 1 before the port is bound.
  • Built-in defaults no longer run the app on their own; they only fill gaps for keys the config files don't set.
  • {{ env }} / {{ file }} tokens are resolved once, after all files merge, instead of per file. That's what lets an overlay override a value the base file wrote as {{ env "..." }}.
  • Everything in this repo that starts the portal passes the flag: the Docker entrypoint (base path overridable via APIP_DP_CONFIG_PATH) and the start / debug npm scripts.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Developer Portal now requires explicit --config paths, supports ordered TOML overlays with deep table merging and array replacement, interpolates after merging, and fails fast on configuration errors. Container and local development entrypoints pass the default configuration path.

Changes

Developer Portal configuration loading

Layer / File(s) Summary
Config parsing and merge primitives
portals/developer-portal/src/config/configMerge.js, portals/developer-portal/src/config/configMerge.test.js
Adds CLI path parsing, recursive key conversion, protected deep merging, array replacement, and tests for these behaviors.
Config loading and startup resolution
portals/developer-portal/src/config/configLoader.js
Loads all required config files in order, merges [developer_portal] tables, interpolates once after merging, and exits non-zero on errors or missing config flags.
Startup entrypoints and configuration contract
portals/developer-portal/docker-entrypoint.sh, portals/developer-portal/package.json, portals/developer-portal/configs/config*.toml
Passes explicit config paths from container and development scripts and documents overlay precedence and default behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: krishanx92, lasanthas, renuka-fernando, tharsanan1, virajsalaka

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning Only Purpose and a Summary are provided; the template's Goals, Approach, tests, security, docs, and environment sections are missing. Add the missing template sections: Goals, Approach, user stories, documentation, automation/security tests, samples, related PRs, and test environment.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title is concise and accurately captures the main change: adding repeatable --config support.
✨ 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.

@Piumal1999

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@portals/developer-portal/src/config/configLoader.js`:
- Around line 66-69: Update the configuration-loading function around
snakeToCamelDeep and the final return of merged to reject an empty merged portal
configuration after all layering is complete. Check whether merged has any own
keys, and fail fast before returning it when none exist, while preserving the
existing merged result for non-empty configurations.

In `@portals/developer-portal/src/config/configMerge.js`:
- Around line 39-46: Update snakeToCamelDeep so Date instances are returned
unchanged before the generic object-recursion branch. Preserve the existing
recursive conversion for ordinary tables and nested objects.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7d1a486c-f152-43bb-8436-5031073efdd8

📥 Commits

Reviewing files that changed from the base of the PR and between 41672fe and 244c666.

📒 Files selected for processing (7)
  • portals/developer-portal/configs/config-template.toml
  • portals/developer-portal/configs/config.toml
  • portals/developer-portal/docker-entrypoint.sh
  • portals/developer-portal/package.json
  • portals/developer-portal/src/config/configLoader.js
  • portals/developer-portal/src/config/configMerge.js
  • portals/developer-portal/src/config/configMerge.test.js

Comment thread portals/developer-portal/src/config/configLoader.js
Comment thread portals/developer-portal/src/config/configMerge.js
@Piumal1999 Piumal1999 changed the title Support repeatable --config flag [Devportal] Support repeatable --config flag Jul 30, 2026
@lasanthaS
lasanthaS merged commit 4168d44 into wso2:main Jul 30, 2026
8 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.

Developer Portal: support repeatable --config flag, make it required

2 participants