Skip to content
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

Search does not return root page, when root is not a workpace parent level page #32

Closed
aahnik opened this issue May 19, 2021 · 16 comments
Closed

Comments

@aahnik
Copy link
Contributor

aahnik commented May 19, 2021

This is weird. I think this is a problem with Notion API and not this library. But opening this issue, so that it can be closed when this is solved.

Problem

Suppose I create a page "my page name", and add my integration to this page, then

notion.search(query="my page name")

will not give this page.

If I query for any subpage/database in this page/page within a database on this page, I will get it successfully.

Steps to reproduce

Create a new integration named "Issue32Inti".

Duplicate this page https://www.notion.so/aahnik/notion-sdk-py-540f8e2b79914654ba103c5d8a03e10e and [update]* put it inside a parent level page .share this with your integration.

Note: the page should be a subpage. Not a parent-level page. ie, it should be inside a parent page.

Now, Initialize your client object notion.

Root page

obj = notion.search(query="notion-sdk-py") # root page
Result ❌
   { 'object': 'list',
      'results': [],
      'next_cursor': None,
      'has_more': False,
    } 

Database

obj = notion.search(query="People") # database
Result ✅
{ 'object': 'list',
 'results': [{'object': 'database',
   'id': '99572135-4646-49bd-95a1-4ff08f79c7a5',
   'created_time': '2021-05-19T04:50:21.634Z',
   'last_edited_time': '2021-05-19T04:57:00.000Z',
   'title': [{'type': 'text',
     'text': {'content': 'People', 'link': None},
     'annotations': {'bold': False,
      'italic': False,
      'strikethrough': False,
      'underline': False,
      'code': False,
      'color': 'default'},
     'plain_text': 'People',
     'href': None}],
   'properties': {'Tags': {'id': 'EcDa',
     'type': 'multi_select',
     'multi_select': {'options': [{'id': '2cd67f95-2f58-4223-bc0a-de03bf87c1e2',
        'name': 'python',
        'color': 'default'},
       {'id': 'f2ae0eef-5611-4da8-97e0-9208ecec44c1',
        'name': 'expert',
        'color': 'blue'},
       {'id': '573d40b5-42bd-4035-815d-73fc4aa7d208',
        'name': 'learner',
        'color': 'purple'}]}},
    'Website': {'id': 'Z{nX', 'type': 'url', 'url': {}},
    'GitHub': {'id': '`<Mi', 'type': 'rich_text', 'rich_text': {}},
    'Name': {'id': 'title', 'type': 'title', 'title': {}}}}],
 'next_cursor': None,
 'has_more': False}

Subpage

obj = notion.search(query="Subpage 1") # subpage
Result ✅
{ 'object': 'list',
 'results': [{'object': 'page',
   'id': '4e8705d7-e6a5-4b23-853f-3b2fcc9f18fe',
   'created_time': '2021-05-19T04:45:47.349Z',
   'last_edited_time': '2021-05-19T04:49:00.000Z',
   'parent': {'type': 'page_id',
    'page_id': '540f8e2b-7991-4654-ba10-3c5d8a03e10e'},
   'archived': False,
   'properties': {'title': {'id': 'title',
     'type': 'title',
     'title': [{'type': 'text',
       'text': {'content': 'Subpage 1', 'link': None},
       'annotations': {'bold': False,
        'italic': False,
        'strikethrough': False,
        'underline': False,
        'code': False,
        'color': 'default'},
       'plain_text': 'Subpage 1',
       'href': None}]}}}],
 'next_cursor': None,
 'has_more': False}

[update] means that portion was later edited.

@aahnik aahnik changed the title The root page is not returned by Notion API Search does not return root page May 19, 2021
@Blucknote
Copy link

From the doc

🚧 Search indexing is not immediate
If an integration performs a search quickly after a page is shared with the integration (such as immediately after a user performs OAuth), the response may not contain the page.
When an integration needs to present a user interface that depends on search results, we recommend including a Refresh button to retry the search. This will allow users to determine if the expected result is present or not, and give them a means to try again.

May be you hit that?

@aahnik
Copy link
Contributor Author

aahnik commented May 20, 2021

Hi @Blucknote, I have waited for a sufficient amount of time, also cleared all cache, and retried several times. I could get all subpages, and everything within the page, but not the root page.

@Blucknote
Copy link

Hi @Blucknote, I have waited for a sufficient amount of time, also cleared all cache, and retried several times. I could get all subpages, and everything within the page, but not the root page.

I'm tried to do a "raw" request and it seems working to me. You can see workspace parent of my page (root?).
May be I'll try later with SDK

curl -X POST 'https://api.notion.com/v1/search' \      
-H 'Authorization: Bearer '"$NOTION_API_KEY"'' \      
-H 'Content-Type: application/json' \
  -H "Notion-Version: 2021-05-13" \  
        --data '{
    "query":"a page",        
    "sort":{
      "direction":"ascending",
      "timestamp":"last_edited_time"
    }
  }'
{
  "object": "list",
  "results": [
    {
      "object": "page",
      "id": "b092fabd-559f-44dc-b638-93050c3e50f6",
      "created_time": "2021-05-20T07:15:00.000Z",
      "last_edited_time": "2021-05-20T07:32:00.000Z",
      "parent": {
        "type": "workspace",
        "workspace": true
      },
      "archived": false,
      "properties": {
        "title": {
          "id": "title",
          "type": "title",
          "title": [
            {
              "type": "text",
              "text": {
                "content": "a page",
                "link": null
              },
              "annotations": {
                "bold": false,
                "italic": false,
                "strikethrough": false,
                "underline": false,
                "code": false,
                "color": "default"
              },
              "plain_text": "a page",
              "href": null
            }
          ]
        }
      }
    }
  ],
  "next_cursor": null,
  "has_more": false
}

@aahnik
Copy link
Contributor Author

aahnik commented May 20, 2021

I'm tried to do a "raw" request and it seems working to me.

Have you followed the exact steps as described in the issue?

@Blucknote
Copy link

Have you followed the exact steps as described in the issue?

Not yet. Will try to duplicate. Without that search with SDK is fine

@Blucknote
Copy link

Have you followed the exact steps as described in the issue?

Duplicated your page and tried with SDK. Working just fine - parent workspace.
My integration name differs but I'm pretty sure it's not a problem.

from pprint import pprint
pprint(
    notion.search(query="notion-sdk-py")
)
{'has_more': False,
 'next_cursor': None,
 'object': 'list',
 'results': [{'archived': False,
              'created_time': '2021-05-20T08:13:48.050Z',
              'id': 'ef3910ee-e6a3-4274-b7b6-722ab00c3265',
              'last_edited_time': '2021-05-20T08:16:00.000Z',
              'object': 'page',
              'parent': {'type': 'workspace', 'workspace': True},
              'properties': {'title': {'id': 'title',
                                       'title': [{'annotations': {'bold': False,
                                                                  'code': False,
                                                                  'color': 'default',
                                                                  'italic': False,
                                                                  'strikethrough': False,
                                                                  'underline': False},
                                                  'href': None,
                                                  'plain_text': 'notion-sdk-py',
                                                  'text': {'content': 'notion-sdk-py',
                                                           'link': None},
                                                  'type': 'text'}],
                                       'type': 'title'}}}]}

@aahnik
Copy link
Contributor Author

aahnik commented May 20, 2021

I don't know what's wrong with my setup. I am still getting the same result, as I described in the issue. Did you try with a new integration? The integration must not have access to the parent page. Just share the "notion-sdk-py" page with the integration.

@Blucknote
Copy link

I don't know what's wrong with my setup. I am still getting the same result, as I described in the issue. Did you try with a new integration? The integration must not have access to the parent page. Just share the "notion-sdk-py" page with the integration.

Me neither. Just created a new integration and shared just diplicated page and still working correctly.
Also i noticed there is no way to delete integrations

image

image

@Blucknote
Copy link

By the way did you tried with another top level (workspace parent) page? I don't think there can be problem with certain page but still

@aahnik
Copy link
Contributor Author

aahnik commented May 23, 2021

another top-level (workspace parent) page

By the word "root", I did not mean workspace parent page. I meant the page that is shared with the integration. All the subpages are automatically shared with the integration.

The page "notion-sdk-py" was not in workspace parent in my case. It was inside a page called "Scratch". "Scratch" had many pages, but only "notion-sdk-py" was shared with integration. I could access all the subpages of "notion-sdk-py", but not itself.

Now, I share my "Home" (workspace parent level) page with the integration, and the search worked perfectly fine for "Home".

I updated my original issue description.

@aahnik aahnik changed the title Search does not return root page Search does not return root page, when root is not a workpace parent level page May 23, 2021
@Blucknote
Copy link

The page "notion-sdk-py" was not in workspace parent in my case. It was inside a page called "Scratch". "Scratch" had many pages, but only "notion-sdk-py" was shared with integration. I could access all the subpages of "notion-sdk-py", but not itself.

Now when i moved "notion-sdk-py" page into not shared one I also getting empty results now. May be we should issue Notion support with this.

@aahnik
Copy link
Contributor Author

aahnik commented May 25, 2021

Hi @makenotion and @ramnes please look at this issue.

@ramnes
Copy link
Owner

ramnes commented May 25, 2021

I don't think highlighting an org is of much use. You'd have more luck on Notion devs Slack server. :P

I don't see any reason the library would cause this. What if you try with curl or any other tool?

@Blucknote
Copy link

@aahnik I noticed something interesting.
Move page shared with integration into page which does not.
On this step nothing suspecious. But
When you move page on workspace level it does not shared with integration anymore

@aahnik
Copy link
Contributor Author

aahnik commented May 25, 2021

I don't see any reason the library would cause this.

I also thought that. But I am now confused. Curl and notion-sdk-py are giving different results. That is surprising.

Curl is giving way more results. When I am doing a search,

curl -X POST 'https://api.notion.com/v1/search' \
  -H 'Authorization: Bearer '"$NOTION_API_KEY"''
	-H 'Content-Type: application/json' \
  -H "Notion-Version: 2021-05-13" \
	--data '{
    "query":"notion-sdk-py",
  }'

I am getting this (content within that page).

Using the library, I am getting nothing. (same code and result as described in issue body).

@ramnes
Copy link
Owner

ramnes commented Nov 30, 2022

Closing due to the lack of activity but if anyone still has the issue, feel free to comment and I'll reopen. :)

@ramnes ramnes closed this as completed Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants