question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Collections key not found with library

See original GitHub issue

I’m curious about the difference between Collection.get() and Collection.iter(key=[KEY])

>>> key = '456/789'
>>> store = project.collections.get_store('trump')
>>> store.set({'_key': key, 'value': 'abc'})
>>> print(store.list(key=[key]))

[{'value': 'abc', '_key': '456/789'}]  # https://storage.scrapinghub.com/collections/9328/s/trump?key=456%2F789&meta=_key

>>> try:
>>>     print(store.get(key))
>>> except scrapinghub.client.exceptions.NotFound as e:
>>>     print(getattr(e, 'http_error', e))

404 Client Error: Not Found for url: https://storage.scrapinghub.com/collections/9328/s/trump/456/789

I assume that Collection.get() is a handy shortcut for the key-filtered .iter() function so I guess the point of my issue is that .get() will raise an exception if given bad input, for example slashes

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ejuliocommented, Jan 21, 2019

I think we could add some docs here, or here https://doc.scrapinghub.com/api/collections.html#access-a-record about this subject. Last week it took me a few minutes to discover that everything was ok, but the endpoint did not allow for a / in the key name.

0reactions
ejuliocommented, Feb 7, 2019

Given @stav PR above, I think we could work on a fix for .get() to always query using query string instead of pretty urls. What do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting an error while publishing the library - " System ...
Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary." error. This error is not specific to any xaml file, ...
Read more >
Best way to handle a KeyNotFoundException - Stack Overflow
I run a bunch of keys through the dictionary, and I expect some keys to not have a value. I catch the KeyNotFoundException...
Read more >
KeyNotFoundException Class (System.Collections.Generic)
A KeyNotFoundException is thrown when an operation attempts to retrieve an element from a collection using a key that does not exist in...
Read more >
Collections - Robot Framework
Collections is Robot Framework's standard library that provides a set of keywords for ... Fails if key is not found from dictionary ....
Read more >
collections — Container datatypes — Python 3.11.1 ...
Source code: Lib/collections/__init__.py This module implements specialized ... Lookups search the underlying mappings successively until a key is found.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found