We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.

Forum Discussion

Здравко's avatar
Здравко
Legendary | Level 20
2 months ago

API detects of wrong/non-existing content change

Hello,

I have an issue with calling /2/files/list_folder/longpoll. For whatever reason, this endpoint activates from and detects changes that are not on the observed folder, but outside it. Something that according documentation shouldn't happen, but it happens. This disturbs application workflow and significantly decrease the efficiency - instead of one or two changes tracking, lot of folders trackers start calling /2/files/list_folder/continue simultaneous - something completely meaningless.

Simplistic example with 3 folders and one file move between 2 of them reproduces the issue:

#!/bin/bash
##############################################################################
#                     Strange firing "NO event" events!?
#                     ==================================
# Save this file as "fropbox_bugtest" for instance and make it executable:
#   $ chmod a+x fropbox_bugtest
#
# Set valid access token
# (like from here - https://dropbox.github.io/dropbox-api-v2-explorer/ )
# and, at the end, just run it:
#   $ ./fropbox_bugtest
#
##############################################################################

ACCESS_TOKEN="PUT VALID ACCESS TOKEN HERE"

# Creating of 3 completely new independent empty folders:
curl https://api.dropboxapi.com/2/files/create_folder_v2 \
  --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \
  -d '{"path":"/Folder1"}' > /dev/null 2> /dev/null
curl https://api.dropboxapi.com/2/files/create_folder_v2 \
  --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \
  -d '{"path":"/Folder2"}' > /dev/null 2> /dev/null
curl https://api.dropboxapi.com/2/files/create_folder_v2 \
  --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \
  -d '{"path":"/Folder3"}' > /dev/null 2> /dev/null

# Put a test file in the first folder:
curl https://content.dropboxapi.com/2/files/upload \
  --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/octet-stream' \
  -H 'Dropbox-API-Arg: {"path":"/Folder1/test.txt"}' \
  -d 'Hello World' > /dev/null 2> /dev/null

# Let's be observing what's going on about all folders:
observeFolder() {
  local ID
  ID=`curl https://api.dropboxapi.com/2/files/list_folder/get_latest_cursor \
    --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \
    -d "{\"include_deleted\":true,\"path\":\"$1\"}" 2> /dev/null \
    | jq -r .cursor`
  echo "Observing '$1'..."
  echo "$1 result:" $'\n' `\
  curl https://notify.dropboxapi.com/2/files/list_folder/longpoll \
    -H 'Content-Type: application/json' -d "{\"cursor\":\"$ID\"}" \
    2> /dev/null` $'\n' `\
  curl https://api.dropboxapi.com/2/files/list_folder/continue \
    --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \
    -d "{\"cursor\":\"$ID\"}" 2> /dev/null \
    | jq '{entries:.entries,has_more:.has_more}'` $'\n'
}

observeFolder "/Folder1" &
P1="$!"
observeFolder "/Folder2" &
P2="$!"
observeFolder "/Folder3" &
P3="$!"

# Wait for a moment to make sure the observe got started.
sleep 1

# Let's move the test file between 2 of the folders:
curl https://api.dropboxapi.com/2/files/move_v2 \
  --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \
  -d '{"from_path":"/Folder1/test.txt","to_path":"/Folder2/test.txt"}' \
  > /dev/null 2> /dev/null
echo 'test.txt got moved from /Folder1 to /Folder2'

# Wait to see what's going on with observations.
wait "$P1"
wait "$P2"
wait "$P3"
echo "The test is over."

# Some cleanup:
curl https://api.dropboxapi.com/2/files/delete_batch \
  --oauth2-bearer "$ACCESS_TOKEN" -H 'Content-Type: application/json' \
  -d `jq -c '{entries:[{path:.[]}]}' <<< '["/Folder1","/Folder2","/Folder3"]'` \
  > /dev/null 2> /dev/null

In fact 2 folders out of 3, in total, get changed. What is the expected output of the above script? 🤔

It's easy it be run and... the output observed. How many {"changes":true} have to be there and {"changes":false} accordingly? 🧐 How many are they actually? Why?

Any thoughts and proposals are welcome.

Thanks in advance.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Thanks for the detailed report. This is a known issue with the /2/files/list_folder/longpoll functionality; it currently does not restrict its change detection to the specific path set for the supplied cursor. This is open with the team, but I don't have a timeline for a resolution. I'll follow up here with any news.

    • Здравко's avatar
      Здравко
      Legendary | Level 20

      Thanks for clarification Greg-DB.

      Hope this will be solved soon.

       

      ADD: Just for completeness: It's not related to path only - even when cursor points to ID, the behavior is still the same.

About Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,875 PostsLatest Activity: 3 hours ago
323 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!