Skip to content

'select' with invalid attribute names fails silently #3

Description

@campbellr

Example:

select with valid attributes:

>>> v1.Scope.filter("Name='My Project'").select('Name', 'AssetType').first()
Scope(71376).with_data({'AssetType': 'Scope', 'Name': 'My Project'})

select with an invalid attribute name (eg: Number)

>>> v1.Scope.filter("Name='My Project'").select('Name', 'AssetType', 'Number').first()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/campbr9/.virtualenvs/v1cli/lib/python2.6/site-packages/v1pysdk-0.2-py2.6.egg/v1pysdk/query.py", line 92, in first
    return list(self)[0]
IndexError: list index out of range

This is a bit deceptive, because there is no way of telling if you supplied the select wrong, or there actually wasn't anything that matched the query.

Interestingly enough, an error is reported by the API, it just isn't propagated to the user:

GET: http://versionone.example.com/VersionOne/rest-1.v1/Data/Scope/71376?sel=Name,Number

<Error href="/VersionOne/rest-1.v1/Data/Scope/71376?sel=Name,Number">
<Message>Invalid SEL parameter</Message>
<Exception class="VersionOne.MetaException">
<Message>Unknown token: Number</Message>
</Exception>
<Exception class="VersionOne.MultipleException">
<Message>
(1) Unknown AttributeDefinition: Scope.Number (2) Unknown token: Number
</Message>
</Exception>
</Error>

Thanks,

Ryan

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions