Skip to content

Load API URL for optional form validations - #829

Open
jmtdev0 wants to merge 1 commit into
medic:mainfrom
jmtdev0-open-source:fix/759-optional-instance-api-url
Open

jmtdev0 wants to merge 1 commit into
medic:mainfrom
jmtdev0-open-source:fix/759-optional-instance-api-url

Conversation

@jmtdev0

@jmtdev0 jmtdev0 commented Jul 2, 2026

Copy link
Copy Markdown

Summary

Fixes #759 by making the API URL available to optional instance-aware form validations when the user explicitly provides instance configuration.

The validate-*-forms actions keep requiresInstance: false because they can run fully offline. However, some individual validations can use the CHT instance when one is available, for example to load the CHT version and decide whether a deprecation warning applies. Before this change, running only validate-*-forms with --url still left environment.apiUrl unset, so those optional instance validations were skipped.

Approach

This PR keeps the offline path unchanged and only resolves apiUrl when either:

  • at least one selected action requires an instance; or
  • the user explicitly supplied instance configuration with --local, --instance, --url, or --archive.

That means purely offline validation commands do not call getApiUrl, while commands such as cht --url=... validate-contact-forms now populate environment.apiUrl for optional validations. This also avoids swallowing invalid instance configuration: if the user provides instance options, getApiUrl is allowed to validate them normally.

The availability check remains gated by requiresInstance, so optional validations can receive apiUrl without making the whole action require a live instance.

Testing

  • npx eslint src/lib/main.js test/lib/main.spec.js
  • npx mocha test/lib/main.spec.js
  • FORCE_COLOR=1 npm test (851 passing, 1 pending)

This PR was developed by Codex with supervision from jmtdev0.

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.

API URL not recognized when only performing validate-*-forms actions

1 participant