Menu

#1929 KPScript should return an error when called to get an entry field that does not exist

KeePass_2.x
closed
nobody
None
5
2014-11-18
2014-09-24
No

For example, the following should fail:

KPScript -c:GetEntryString "C:\KeePass\MyDb.kdbx" -pw:MyPassword -Field:SomeFieldThatDoesNotExistInDatabase -ref-Title:"Demo Account"

But now it returns 'OK: Operation completed successfully.'

Discussion

  • Dominik Reichl

    Dominik Reichl - 2014-09-24
    • status: open --> closed
     
  • Dominik Reichl

    Dominik Reichl - 2014-09-24

    I disagree; returning an empty data set (due to querying a non-existent field) is not an error.

    Best regards,
    Dominik

     
  • Petros Moisiadis

    I truly respect your disagreement, but let me try to explain in which cases this can be problematic or suboptimal.

    With current behavior you cannot differentiate between an existing field that is not set and a non-existing field. In both cases an empty data set will be returned. This can be a problem with custom fields that should exist, but they are not, due to incomplete data entry (a human forgot to add these fields). How can you programmatically catch a possible miss out and not assume that the field exists but is not set? You cannot assume that the person doing the data entry knows about the custom field or that he/she will always remember to add it. So, by returning an error when a custom field is missing, you can protect your program logic from such kind of incomplete data entries.

    Another case for reporting a request for a non-existent field as an error has to do with protection from typos on user input. Let's say that you want to get the username, but you are typing it as 'Username' and not as 'UserName'. Normally, you want a hint that 'Username' does not exist, otherwise it is highly possible to think that the username is not set.

     
  • Dominik Reichl

    Dominik Reichl - 2014-09-24

    I've now added an option '-FailIfNotExists'. By passing it together with the 'GetEntryString' command, you get the behavior that you suggested.

    Here's the latest KPScript development snapshot for testing:
    http://keepass.info/filepool/KPScript_140924.zip

    Moving to closed feature requests.

    Best regards,
    Dominik

     
  • Dominik Reichl

    Dominik Reichl - 2014-09-24

    Ticket moved from /p/keepass/bugs/1292/

     
  • Petros Moisiadis

    I just tested it and it works. Thanks!

     

Log in to post a comment.