-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created API key empty just after uploading a table #15466
Comments
@Jesus89 This seems a bug of CARTOframes itself. If no client has reported this, I think it should be dealt as a CARTOframes issue/bug and not as an RT issue. |
Hi @oriolbx. It's a bug in CartoDB because the API keys creation fails and it does not return any Exception. The lib carto-python should be also checked. CARTOframes is the way we have detected that bug and also, in order to fix this in CF, it must be fixed in CartoDB first. The RT tag was added by @cmongut so maybe he can explain better the need for this to be in RT. |
Oh ok, thanks! Sorry for the confusion. |
@Jesus89 I'm not able to reproduce the issue at all. Do we have a notebook that consistently fails? That would be helpful. Thanks! |
[Notebook sent] :) You can find more information in the original issues linked in the description. Q: do we have deployed changed related to API keys generation in the last 10 days? |
I cannot reproduce the issue, thus I don't know what happened, but I've checked one of the wrong API keys are correct in our metadata database and the pg_role was created, but it hadn't any GRANT. I'm going to force that very same error introducing an exception in the moment the permissions are granted, and do an E2E test locally to see what happens. |
I've checked that any error sent by our API arrives to the client and it's reported to the user, so that's just fine. Besides that I spotted the issue: I've been looking at Kibana and I'm seeing several 422 errors in the POST to the api_keys endpoint and then a GET with a proper api_key name, so I'm assuming it is this part of the code which is being executed. Basically, in CARTOframes the API key name is built from a hash of the layer names, which seems legit in order to reuse API keys. Since the API key name is unique, if the server raises a The problem is the table referenced in the API key might not exist, so CF retrieves an API key that does not have any table granted, since the original table was previously dropped, the reference was lost and the API key is never created again. To reproduce this:
There are a number of possible solutions to this situation:
|
After a meeting we found 3 options:
Option 1 is an improvement in CARTOframes, and we should evaluate it to improve the Option 2 needs research (@alrocar) Option 3 can also be implemented, but we need to test it to make sure it helps/solves the issue. |
If someone deletes the table from their dashboard and then, upload another one with the same name from CARTOframes, will we continue having the same issue?
How this will impact the performance? |
Yes, I think is someone drops a table with the SQL API or the Dashboard the issue can happen again. There is no performance impact AFAIK with option 3. |
Should we go fo option 3 then? Thoughts @alrocar? |
After talking to @cmongut we'll go with option 3, although it's not super-prioritary 😛 |
ping @alrocar |
So we decided to go with option 3:
ensure the grants on a GET request is not a nice solution. A GET request should not modify the underlying resource. So I'm proposing this other approach:
The detailed steps to implement this (in case it can be implemented inside the CF project, otherwise ask for help to the backend team):
api_key = self._api_key_manager.get(name)
api_key.touch() #or api_key.refresh_grants() This looks more complicated than it actually is, but I prefer it as a solution, better than doing non-standard things in a GET method. Apart from that, I might be missing something as I've been writing as things came up to my head |
In any case, remember this just solves the case of ensuring publication of maps with right api_key grants. If the map is not re-published, eventually the API key role might have no grants and the map be broken anyway. |
Thanks @alrocar |
Fixed in CartoDB/cartoframes#1633, CartoDB/cartoframes#1628. Release 1.0.3 |
Context
This bug has been found using CARTOframes. When a map that uses a private table is published a Maps API key is created.
Steps to Reproduce
Using CARTOframes:
to_carto(gdf, 'new_table_name', if_exists='replace')
map_viz = Map(Layer('new_table_name'))
map_viz.publish(name='New_Table_Name', password='1234', if_exists='replace')
Current Result
If the table has been just uploaded the API key is not properly created (empty tables) and there is no Exception from the backend.
Expected result
API key creation should work or at least raise an Exception.
Additional info
Related to:
cc @CartoDB/rt-managers
The text was updated successfully, but these errors were encountered: