How should an interactive app form signal that it is invalid (empty options / API error) without breaking the dashboard?

Context

We have an interactive app whose select options are populated by calling an external API from form.yml.erb (OpenStack flavors). That call can legitimately fail — the API returns an empty array, times out, or raises. When it does, the form renders a select with no options, and the user can still hit Launch, submitting the session with a blank value for that attribute.

What we’d like to achieve

The form should be visibly invalid and the session should not launch. Either:

  1. the Launch button is disabled while a required form item has no available options, or
  2. the form renders an error state that blocks submission, with a message explaining why.

What we’ve tried

  • required: true on the empty select — does not block submission. We understand from the docs that required, min and max are client-side validation only, and a select with zero options doesn’t appear to be covered by that check.
  • Raising an exception from form.yml.erb — this is what we’d naturally do to signal “the form is not usable,” but it doesn’t stay contained to the app’s form page. The exception escapes into the dashboard’s app-list rendering, so after it happens the interactive app stops appearing in the navbar dropdowns.
  • Conditionally omitting the form item and showing form_header — this is our current workaround. It renders a clean explanation, but the Launch button is still live and submits with the attribute absent.
  • form.js to disable the submit button — works, but it’s client-side only, easy to bypass, and we’d rather express “this form is currently invalid” in the form configuration itself.

Questions

  1. Is there an existing, supported way to mark a rendered form as invalid/non-submittable from form.yml.erb (a flag, a validation hook, or a specific error the controller is expected to catch)?
  2. Should a required select with an empty options list block submission, or is that explicitly out of scope for the current validation?
  3. If the intended answer is “write form.js”, would you accept a documented pattern (or a small built-in) for “dynamic options list is empty → disable launch and show this message”?

Environment

  • OnDemand: <4.0.1>

This appears to be a bug with 4.0 that has been fixed in the more recent versions (there were pretty big refactors to form building as part of 4.1, though I have not gone through to see which exactly which versions it affects). In the most recent version (4.2.3 at least), you can specify ‘required:true’ on the select and it will (as expected) block submission as long as there are no options selected. The message it provides is still ‘Please fill out this field’ so I think your form header alerting is still useful.

In 4.0, the required flag never makes it to the select widget, but you can still add it manually with the following line in your form.js

document.getElementById('batch_connect_session_context_ITEM_NAME').setAttribute('required', 'required')

And that allows the client-side validation to block submission and provide feedback about why, even though in this case the user won’t be able to do anything with that feedback other than wait for later.