Skip to content

Guard NumberState format fallbacks#1100

Merged
timbms merged 1 commit intodevelopfrom
feature/numberstate-format-crash-fallback
Apr 5, 2026
Merged

Guard NumberState format fallbacks#1100
timbms merged 1 commit intodevelopfrom
feature/numberstate-format-crash-fallback

Conversation

@timbms
Copy link
Copy Markdown
Contributor

@timbms timbms commented Mar 11, 2026

A crash was reported via TestFlight

Summary

  • validate and normalize NumberState format strings before calling String(format:)
  • fall back to plain number output for unsupported or malformed server patterns
  • add regression coverage for indexed and unsupported format patterns

Testing

  • xcodebuild test -workspace openHAB.xcworkspace -scheme openHABTestsSwift -destination "platform=iOS Simulator,name=iPhone 17 Pro" -only-testing:openHABTestsSwift/NumberStateTests (builds but did not complete with a usable result in the sandbox)
  • swift test --package-path OpenHABCore --filter NumberStateTests (blocked by sandboxed SwiftPM manifest/module-cache permissions)

@TAKeanice TAKeanice force-pushed the openapigen-swiftui branch from 1f242b5 to 166a59c Compare March 26, 2026 19:49
Base automatically changed from openapigen-swiftui to develop March 30, 2026 19:59
@TAKeanice
Copy link
Copy Markdown
Contributor

I like that you are working on properly supporting all format strings from OpenHab. While I think it´s unfortunate that OH just assumes everyone knows that it formats using Java format strings (I did not see much documentation about it, just examples), I can accept it. The Java-printf-style format makes implementation easier for the Android app, too, plus it is simple to understand and locale-aware.

To tackle the Java vs Swift format string incompatibility properly, I once thought we should implement a Java to Swift formatstring conversion. Is this what you did here? If yes, we should publish this as a gist independently - there is nothing like it on the internet yet. If not, what do you think about making this a more comprehensive converter and solve the formatstring problem once and for all?

@timbms
Copy link
Copy Markdown
Contributor Author

timbms commented Apr 3, 2026

To tackle the Java vs Swift format string incompatibility properly, I once thought we should implement a Java to Swift formatstring conversion. Is this what you did here?

Of course it would be ideal if there was a Java to Swift formatstring conversion. This is indeed the problem we are facing here. I was thinking not as big as you. But I love challenges.

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
@timbms timbms force-pushed the feature/numberstate-format-crash-fallback branch from f8f636e to 8fee328 Compare April 5, 2026 20:36
@timbms timbms merged commit 836f186 into develop Apr 5, 2026
2 checks passed
@timbms timbms deleted the feature/numberstate-format-crash-fallback branch April 5, 2026 20:50
@timbms
Copy link
Copy Markdown
Contributor Author

timbms commented Apr 5, 2026

@TAKeanice Let's first address this crash fix. I will follow up with a wider scope.

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.

2 participants