Acknowledged

Doc / sim behavior for Properties.getValue(key) / setValue(key) is inconsistent regarding whether key needs to be present in app properties or settings

The doc for Properties.getValue() claims

Property values must be defined in the application settings xml. If a key that is not present in application settings is passed to getValue(), an exception will be thrown.

But the doc for Properties.setValue() claims

The CIQ Core Topics > Persisting Data docs also says the following for both getValue and setValue:

Property values must be defined in the application settings xml. If a key that is not present in application settings is passed to Properties.getValue(), an exception will be thrown

The actual observed behavior for Properties.getValue("someKey"), on a simulated fr965:

- key present in app properties with string value, with no corresponding setting

getValue() successfully retrieves the corresponding value from properties

- key not present in properties or settings (but application has 0 properties defined in resources):

The following error was returned (at the Properties.getValue() call):

Error: Unexpected Type Error
Details: Failed invoking <symbol>

- key not present in properties or settings (but application has > 0 properties defined in resources)

The following exception was thrown:

Error: Unhandled Exception
Exception: Key does not exist in Application Properties

I verified that this is indeed Properties.InvalidKeyException by catching the exception and using instanceof

See: https://forums.garmin.com/developer/connect-iq/f/discussion/358162/unexpected-type-error/1805266#1805266

It's also worth noting that there's a clear typo in Core Topics > Persisting Data.

Properties.getValue() is accurately described as follows: "Retrieve information by key from properties."

But Properties.setValue() has the following misleading / incorrect description: "Store information by key in persisted storage."

This seems to be a copy-paste error from the description for Storage.getValue() on the same page

  • TL;DR the docs for Properties.getValue()/setValue() (mostly) say that the key has to exist in settings, otherwise an exception will be thrown. But the actual behavior seems to be that the key has to exist in properties.