Open hedss opened 5 years ago
Turns out that this is only the case with ShortUUIDs that do not contain alpha characters (ShortUUIDs containing alpha characters work as expected).
This is caused by this issue in the SDK: https://github.com/balena-io/balena-sdk/issues/826
Reposting for the SDK issue:
This is probably a bug on the CLI side, where capitano is inferring & parsing numeric-only short uuids as numbers. That's already handled in other actions using either the
normalizeUuidProp
util function, or by directly using thepropname_raw
variant (I did fix a few of them back then :smile:) See: https://github.com/balena-io/balena-cli/search?q=normalizeUuidProp&unscoped_q=normalizeUuidProp
Just a note that if the issue is down to CLI/Capitano argument parsing, then another good solution is to convert the command from Capitano to oclif -- which is the plan in any case.
@thgreasi Ah sorry, yeah you're right that the CLI is passing as number instead of string in those cases, so not an SDK issue - sorry for the false alarm :) (I was thrown by the ts string typing).
However it's already using normalizeUuidProp
, and if I understand correctly, I don't see how this could help here. We have a single parameter uuidOrDevice
, which can take both ShortUUIDs and Ids, both of which can be a string of digits with the same length, but one needs to be interpreted as a string, and the other a number. Isn't it impossible to distinguish between the two? (perhaps I am missing something...)
(@pdcastro I think this goes for switching to oclif too)
After discussion with @thgreasi it seems the accepted solution in these ambiguous situations where the param could possibly be interpreted as either a shortUUID or an Id, is two calls to the SDK. One with the number typing (e.g. interpreting as Id), and then if no result a second call with the param converted to a string.
Just make sure to have this as a re-usable helper, like we did for releases, and to avoid repeating the code in several actions. See: https://github.com/balena-io/balena-cli/blob/ede72e1dd2244d469d5decdb68ab2981e6e0d976/lib/utils/normalization.ts#L30
Given short form UUID is available as an argument for every other command,
logs
should accept it as well: