-
Notifications
You must be signed in to change notification settings - Fork 16
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
Getting a KeyError: 'rows' error with Discourse 2.8.0.beta7 #112
Comments
Hi, thanks for trying out our module! You need a very specific table with a specific format. Like this one: The navigation header must exist and have those headers. The previous example is here |
Hi, thank you for your swift reply. I forgot to mention that I use the tutorial module and used an identical table like in the ubuntu tutorials discourse section. I used the table in the past with the older version of the python module, which worked flawlessly. Feel free to take a look here. Does that mean, I do not need a specific discourse query for Data Explorer? |
I took some time to play around with Data Explorer and managed to build a SQL query, which should satisfy the requirements: -- [params]
-- int_list :topics
SELECT cooked
FROM posts
WHERE posts.topic_id IN (:topics)
GROUP BY cooked In my understanding, the python module reads out all topics with there respective topic_id from the table @carkod mentioned. These ids get joined in a string separated by commas and handed over to the SQL query defined in the Data Explorer plugin on the discourse server. So I used a string like def get_topics(self, topic_ids):
"""
This endpoint returns multiple topics HTML cooked content.
This is possible with the Data Explorer plugin for Discourse
we are using it to obtain multiple Tutorials content without
doing multiple API calls.
"""
headers = {
"Accept": "application/json",
"Content-Type": "multipart/form-data;",
}
# Run query on Data Explorer with topic IDs
topics = ",".join([str(i) for i in topic_ids])
response = self.session.post(
f"{self.base_url}/admin/plugins/explorer/"
f"queries/{self.get_topics_query_id}/run",
headers=headers,
data={"params": f'{{"topics":"{topics}"}}'},
)
return response.json()["rows"] Unfortunately, I still get the same error in my app server. Only the error on the discourse server change from code 404 to 442. Any ideas on where I am wrong? Thank you! |
Another minor addition to the issue. I run two additional tests to identify the cause of the problem:
Both tests yield the same result - KeyError. |
Just to briefly follow up with how I dealt with the issue. I downgrade to Discourse 2.6.7 and my old setup worked again. I assume it relates to #101 as Discourse changed how headers are treated. |
Hi,
first, thank you for the great work and for sharing it!
I use Discourse 2.8.0.beta7 and run a flask app containing only the python module.
Running the app in debug mode, I get the following output:
If I understand it properly, the troubles come from line 57 to 62, where the API call takes place:
The respective logs from my server (404 Code) indicate that the call is unsuccessful:
If I am not mistaken, I require the Data Explorer Plugin for discourse to make it work. I installed it and would guess I need to create a query for Data Explorer? Could somebody help me out with a template or something?
I would suspect, that the answer is somewhere in the TutorialParser (tutorial.py), but I cannot get my head around it.
Thank you in advance!
The text was updated successfully, but these errors were encountered: