appmanifest: validate fap_version type; accept int, reject float (refs ufbt#52) - #4375
appmanifest: validate fap_version type; accept int, reject float (refs ufbt#52)#4375hypery11 wants to merge 1 commit into
Conversation
|
This one's pure Python (the manifest validation logic), so fully testable without hardware. Extracted |
|
The float rejection is the right call, and your diagnosis is right too: patching A list works today. Six apps currently in flipper-application-catalog use that form. I checked every manifest at its pinned
The catalog builds those with
elif isinstance(self.fap_version, (tuple, list)):
self.fap_version = tuple(self.fap_version)
else:
raise FlipperManifestException(
f"fap_version must be a string like '1.2' or a tuple like (1, 2), "
f"got {type(self.fap_version).__name__}: {self.fap_version!r}"
)That also cleans up something the current patch leaves as-is: with a list, Separate and smaller: the Last thought, purely about getting this merged: the float rejection fixes ufbt#52, the int shorthand is a new feature. They've been sitting together since May. Splitting the float part out might move faster on its own. Not a maintainer, just read through it. |
Refs flipperdevices/flipperzero-ufbt#52.
What this fixes
When a user writes
fap_version=1.0(a Python float literal) inapplication.fam, the currentFlipperApplication.__post_init__silently lets that survive — it only normalisesfap_versionif it's astr. The TypeError only surfaces deep in the build step, inscripts/fbt_tools/fbt_extapps.py:_setup_app_env:…with the cryptic
TypeError: 'float' object is not iterable, becausefloatitself isn't iterable.The original reporter on ufbt#52 proposed patching
fbt_extapps.py, but that doesn't help —map(str, 1.0)raises the same TypeError. The right place to catch it is the manifest schema validation, where the error message can name the actual problem.What the patch does
In
FlipperApplication.__post_init__, after the existingappidregex check:int—fap_version=1becomes(1, 0). Matches the common shorthand.boolis explicitly excluded (it subclassesint).floatwith a clear message explaining why floats are unsafe for version numbers (1.10becomes1.1at the Python literal level).list, etc.) at the manifest layer, naming the type received.The existing
strandtuplepaths are unchanged.Verification
Ran 7 cases against the patched dataclass:
All previously-valid inputs (
str,tuple, default) still pass through unchanged.Scope
One file, +30 / -2 lines, no public API change. The new behaviour is strictly additive (int accepted) and stricter (float/list/bool now rejected at manifest time instead of crashing later). Existing valid manifests are unaffected.