Prefer using oneOf over enums in policy schema
Categories
(Enterprise Products :: Firefox, enhancement, P1)
Tracking
(firefox155 fixed)
| Tracking | Status | |
|---|---|---|
| firefox155 | --- | fixed |
People
(Reporter: bsmth, Assigned: bsmth)
References
Details
Attachments
(1 external file)
The policy schema expresses some allowed values as enums:
"enum": [2, 3]
We have the opportunity to express these as oneOf values with more information, instead:
"oneOf": [
{
"const": 2,
"title": "Block access",
"description": "Block websites from accessing serial ports. The setting is locked so users cannot change it."
},
{
"const": 3,
"title": "Allow access",
"description": "Allow websites to request access to serial ports. Users can still turn this off manually."
}
]
This will be better for documentation and policy editors, with the downside of producing more verbose errors in PolicySchemaValidator. If these are problematic or not ergonomic to debug in cases where you provide a wrong value, we can follow up with error formatting later.
| Assignee | ||
Comment 1•4 months ago
|
||
| Assignee | ||
Comment 3•4 months ago
|
||
I suppose it's not that bad, but for illustration, if you provide a wrong value for HttpsOnlyMode:
Before:
Invalid parameters specified for HttpsOnlyMode: Instance does not match any of
["allowed","disallowed","enabled","force_enabled"]. (at #)
After:
Invalid parameters specified for HttpsOnlyMode: Instance does not match exactly one
subschema (0 matches). (at #); Instance does not match "allowed". (at #); Instance
does not match "disallowed". (at #); Instance does not match "enabled". (at #);
Instance does not match "force_enabled". (at #)
It's a little harder to read with all of the repeated Instance does not match…, especially if there's many possible values. Just noting so we're aware of that.
Comment 4•4 months ago
|
||
Should we fix that in cfworker? :)
I love these changes, but the more we diverge from the ESR, the more painful things are going to be to merge to it.
Just something to keep in mind.
Comment 5•4 months ago
|
||
Some of these descriptions seem really verbose (and unnecessary).
Do we foresee using them somewhere?
| Assignee | ||
Comment 6•4 months ago
|
||
(In reply to Mike Kaply [:mkaply] from comment #4)
Should we fix that in cfworker? :)
There's nothing to fix there as far as I understand, but we can change https://searchfox.org/firefox-main/source/toolkit/components/enterprisepolicies/PolicySchemaValidator.sys.mjs#102 the formatter so we make it a little easier for humans to read. It's a "nice to have", though, in my opinion.
I love these changes, but the more we diverge from the ESR, the more painful things are going to be to merge to it.
Just something to keep in mind.
Gotcha. I think we're nearly done with this topic, so this is as far as the divergence should get.
(In reply to Mike Kaply [:mkaply] from comment #5)
Some of these descriptions seem really verbose (and unnecessary).
Do we foresee using them somewhere?
Yeah, they'll all be surfaced in the console editor. I'll ping Andi who's implementing that for another pair of eyes on it. I'm in the camp of keeping at the current level of detail for UX purposes, but curious what Andi thinks.
Comment 7•4 months ago
|
||
Generally, this touches a thorny subject, because we want to translate all user-facing strings in the UI. Difficult with error messages that bubble up from somewhere. Translating the whole error space of the validator sounds like a huge lift.
Editing the policies with a dedicated UI should prevent errors from happening in the first place, and the JSON editor mode should help with auto-completing such enums. So maybe this is not such a big issue.
Other than that, I think this particular Example is a badly phrased message in any case. It basically says the same as the "before" message, only more complicated, less dense and positively robotic..
Comment 8•4 months ago
|
||
Other than that, I think this particular Example is a badly phrased message in any case. It basically says the same as the "before" message, only more complicated, less dense and positively robotic..
Which example?
Comment 9•4 months ago
|
||
(In reply to Mike Kaply [:mkaply] from comment #8)
Other than that, I think this particular Example is a badly phrased message in any case. It basically says the same as the "before" message, only more complicated, less dense and positively robotic..
Which example?
This one:
Invalid parameters specified for HttpsOnlyMode: Instance does not match exactly one
subschema (0 matches). (at #); Instance does not match "allowed". (at #); Instance
does not match "disallowed". (at #); Instance does not match "enabled". (at #);
Instance does not match "force_enabled". (at #)
Comment 10•3 months ago
|
||
Comment 11•3 months ago
|
||
Comment 12•3 months ago
|
||
Backed out for causing bc failures @browser_container_definitions_in_sync.js.
Comment 13•3 months ago
|
||
| Assignee | ||
Comment 14•3 months ago
|
||
(In reply to agoloman from comment #12)
Backed out for causing bc failures @browser_container_definitions_in_sync.js.
Latest push contains fixes for the test so it now follows the shape of the schema
Comment 15•3 months ago
|
||
| bugherder | ||
| Assignee | ||
Updated•3 months ago
|
Description
•