Document behavior for multiple matches

Right now the documentation is silent on what happens when you run op get item ... and there are multiple matches. By observation I see that it arbitrarily chooses one item and returns that, which is not terribly intuitive. I saw elsewhere in the forums that you've considered changing that behavior, but so long as it is true, it would be good to mention it.


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Sync Type: Not Provided

Comments

  • rickfillionrickfillion Junior Member

    Team Member
    edited February 2019

    You're right. The arbitrary selection really bugs me, and we're pushing more commands towards erroring in the case of multiple matches. So I'm looking forward to us fixing that problem.

    I've filed an issue to get the documentation updated with some info about that until we can get the code change in place.

    Rick

    ref: web/support.1password.com#1345

  • I'd suggest that you consider returning all matches (maybe capped by some ceiling) rather than returning an error, or else make this behavior available by a switch. This would meet the maximum possible use cases.

  • brentybrenty

    Team Member

    Returning all matches might not be very helpful for scripting, but a switch would mitigate that. Definitely something we'll continue to evaluate as the CLI develops. Cheers! :)

  • This is a little contrived, but imagine a script downloading a set of private keys: you may want all possible matches. I think the only way that could be set up intentionally right now is by making them all have the same domain, but it could be possible.

  • brentybrenty

    Team Member

    That's a really great point. I think there may be a good use case for both. :)

  • rickfillionrickfillion Junior Member

    Team Member

    @scottsb : returning multiple would mean sometimes returning an array and sometimes returning an object. That or even when we return a single result we wrap it in an array/structure of some sort.

    We're having trouble deciding how best to do something like that to make it naturally for people using the tool.

    Rick

  • To avoid changing the top level output you could just output a sequence of JSON objects for multiple matches. JQ handles this quite naturally.

    There's even a formal definition for the approach:
    https://datatracker.ietf.org/doc/rfc7464/?include_text=1

  • rickfillionrickfillion Junior Member

    Team Member

    I hadn't considered that approach. Food for thought. Thanks. :)

    Rick

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file