gtalarico / pyairtable

Python Api Client for Airtable
https://pyairtable.readthedocs.io
MIT License
784 stars 138 forks source link

In Table.get can get a record regardless of the table ID #375

Closed Miorey closed 5 months ago

Miorey commented 5 months ago

Version: pyairtable = "^2.3.3" When I create a table and I try to get an element from another table a value is returned. Logically it should raise an error or return None.

Ex: rec00000000000001 is in table tbl00000000000001 rec00000000000002 is in table tbl00000000000002

My code is:

def get_record(airtable_id: str) -> dict:
    api = Api(settings.airtable_api_key)
    table = api.table(settings.airtable_base_id, settings.airtable_table_id_or_name)
    return table.get(record_id=airtable_id)
mesozoic commented 5 months ago

I'm able to reproduce this, but it looks like a behavior of the Airtable API instead of the library. It appears that the Airtable API for retrieving a record by ID does not validate that the table ID in the URL is correct. Whether that's intentional or a bug is anyone's guess.

I don't see a way (or a reason) for the pyAirtable library to second-guess what comes back from Airtable's API, so I'm going to close this issue.

@marks FYI

Miorey commented 5 months ago

@mesozoic I completly agree that it comes from Airtable API.

marks commented 5 months ago

Chiming in to say I have indeed seen this behavior as well and it is an artifact of the Airtable API and not SDK specific. While this idiosyncrasy should not be relied on, I also don't expect it to change soon either.