fabioberger / airtable-go

Golang client library for the Airtable API
MIT License
44 stars 29 forks source link

Update Required for API Key Validation to Accommodate New Airtable API Key Formats #9

Open pascalrossi opened 4 months ago

pascalrossi commented 4 months ago

Hello,

I'm reaching out to address a compatibility issue with the airtable-go library in relation to the latest changes in Airtable's API key format. Airtable has updated their API keys to a new format, which includes a longer length and the use of additional characters such as "." (dot). This change impacts the airtable-go library's ability to validate API keys using the current implementation found in client.go.

Issue Description: The library currently validates API keys with a fixed length of 17 characters and expects them to start with a specific prefix ("key"). This validation is performed by the IsValidAPIKey function in the utils package. However, with Airtable's recent update to their API key format, this validation logic no longer accommodates the new key specifications, potentially leading to valid API keys being incorrectly flagged as invalid.

func isValidAirtableID(id, expectedPrefix string) bool {
    regex := regexp.MustCompile("[a-zA-Z0-9]{17}")
    return len(id) == 17 && strings.HasPrefix(id, expectedPrefix) && regex.Match([]byte(id))
}

Suggested Actions:

  1. Update Validation Logic: Revise the isValidAirtableID function (and by extension, IsValidAPIKey and IsValidBaseID) to support the new API key format. This may involve adjusting the length check and expanding the character set to include "." (dot) among other characters now allowed in Airtable API keys.
  2. Flexible Length Check: Given that API key formats can change, consider making the length check more flexible or removing it altogether, focusing instead on the presence of a valid prefix and ensuring the key consists only of allowed characters.
  3. Enhance Documentation: Update the library's documentation to reflect these changes and provide guidance on the new API key format expectations for users of the airtable-go library.

Impact of Issue: Without these adjustments, users of the airtable-go library who had to migrate to or are using the new Airtable API keys may encounter errors or be unable to use the library to interact with Airtable, hindering the library's applicability and usefulness.

We greatly appreciate the work you've put into developing and maintaining the airtable-go library. Addressing this issue will not only enhance its functionality but also ensure its compatibility with Airtable's evolving platform.

Thank you for considering this request. I'm looking forward to your thoughts on this matter and am happy to contribute to testing or further discussions if helpful.

Best regards Pascal Rossi

patimen commented 4 months ago

Yes, just encountered this, crippling our ability to use the library.

patimen commented 4 months ago

FWIW, as of Feb 20th, old keys are no longer accepted by the Airtable API, so this library is in fact 100% broken and unusable as is.

aloner-pro commented 1 week ago

If you can guide me, I would be happy to fix it. I need this to work too. @pascalrossi @patimen Also in the mean time have you found any work around?