# List --s3-versions files looping bug

**URL:** <https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974>\
**Category:** Suspected Bug\
**Created:** [November 20, 2023, 1:32pm UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974 "2023-11-20T13:32:04Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![cberni](https://forum.rclone.org/user_avatar/forum.rclone.org/cberni/32/19689_2.png) [@cberni](https://forum.rclone.org/u/cberni)\
**Post date:** [November 20, 2023, 1:32pm UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/1 "2023-11-20T13:32:04Z")

</div>

#### What is the problem you are having with rclone?

`rclone ls --s3-versions` is going into an infinite loop repeating the same files.

the problem seems to be with unversioned files. are relisted infinitely. Only killing the process to stop.

Is there any way to list only versioned files?

#### Run the command 'rclone version' and share the full output of the command.

rclone v1.64.2

- os/version: ubuntu 22.04 (64 bit)
- os/kernel: 6.2.0-1018-gcp (x86\_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.21.3
- go/linking: static
- go/tags: none

#### Which cloud storage system are you using? (eg Google Drive)

google cloud storage

#### The command you were trying to run (eg `rclone copy /tmp remote:tmp`)

```auto
rclone ls --s3-versions remote:archive/2022/

```

#### The rclone config contents with secrets removed.

```auto
remote]
type = s3
provider = GCS
access_key_id = 
secret_access_key = 
endpoint = https://storage.googleapis.com

```

#### A log from the command with the `-vv` flag

```auto
2023/11/20 12:43:56 DEBUG : rclone: Version "v1.64.2" starting with parameters ["rclone" "ls" "--s3-versions" "remote:archive/2022/7" "-vv"]
2023/11/20 12:43:56 DEBUG : Creating backend with remote "remote:archive/2022/7"
2023/11/20 12:43:56 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2023/11/20 12:43:56 DEBUG : remote: detected overridden config - adding "{pO73u}" suffix to name
2023/11/20 12:43:56 DEBUG : Resolving service "s3" region "us-east-1"
2023/11/20 12:43:56 DEBUG : fs cache: renaming cache item "remote:archive/2022/7" to be canonical "remote{pO73u}:nd-srv/pacs-data/archive/2022/7"

```

the loop log. rename .log to .rar file  
[log.rar.log](https://forum.rclone.org/uploads/short-url/nhbmTeNfXrbTv4qEEoajFvjcUWB.log) (12.6 KB)

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [November 20, 2023, 8:28pm UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/2 "2023-11-20T20:28:36Z")

</div>

This is usually caused by --s3-list-version being set wrong for the provider. Can you try different versions for that and see if it makes a difference?

> **[Amazon S3](https://rclone.org/s3/#s3-list-version)**
>
> Rclone docs for Amazon S3

---

<div class="post-metadata">

**Author:** ![cberni](https://forum.rclone.org/user_avatar/forum.rclone.org/cberni/32/19689_2.png) [@cberni](https://forum.rclone.org/u/cberni)\
**Post date:** [November 20, 2023, 8:56pm UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/3 "2023-11-20T20:56:50Z")

</div>

I tried `--s3-list-version=1` and `--s3-list-version=2`. same problem.

if remove `--s3-versions` works fine.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [November 20, 2023, 10:43pm UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/4 "2023-11-20T22:43:47Z")

</div>

Can you do a log with -vv --dump bodies that should show what the problem is.

Thanks

---

<div class="post-metadata">

**Author:** ![cberni](https://forum.rclone.org/user_avatar/forum.rclone.org/cberni/32/19689_2.png) [@cberni](https://forum.rclone.org/u/cberni)\
**Post date:** [November 21, 2023, 2:35am UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/5 "2023-11-21T02:35:34Z")

</div>

[log.rar.txt](https://forum.rclone.org/uploads/short-url/hdC1ydjBwqpUZA5sA2I38ghHaWY.txt) (82.7 KB)

rename "log.rar.txt" to "log.txt.rar"

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [November 21, 2023, 10:45am UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/6 "2023-11-21T10:45:18Z")

</div>

Thank you.

It has definitely got stuck in a loop - you can see it fetching the same thing over and over again

```
GET /?delimiter=&encoding-type=url&max-keys=1000&prefix=pacs-data%2Farchive%2F2022%2F8%2F&versions= HTTP/1.1

```

Which is getting a prefix of `pacs-data/archive/2022/8/` when I decode it.

But why is the question?

Looking at the list response we see

```xml
<?xml version='1.0' encoding='UTF-8'?>
<ListBucketResult xmlns='http://doc.s3.amazonaws.com/2006-03-01'>
  <Name>nd-srv</Name>
  <Prefix>pacs-data/archive/2022/8/</Prefix>
  <Marker>
  </Marker>
  <GenerationMarker>
  </GenerationMarker>
  <NextMarker>pacs-data/archive/2022/8/1/10/11992158/8EC0C0C4/77407295</NextMarker>
  <NextGenerationMarker>1683228165974407</NextGenerationMarker>
  <MaxKeys>1000</MaxKeys>
  <IsTruncated>true</IsTruncated>
  <Encoding-Type>url</Encoding-Type>
  <Version>
    <Key>pacs-data/archive/2022/8/1/10/08E75EBF/F9A5759E/271EE0F6</Key>
    <Generation>1683224794134204</Generation>
    <MetaGeneration>1</MetaGeneration>
    <IsLatest>true</IsLatest>
    <LastModified>2023-05-04T18:26:34.136Z</LastModified>
    <DeletedTime>
    </DeletedTime>
    <ETag>"ea549ded855170e0670a00e5d2e13a0a"</ETag>
    <Size>54366</Size>
  </Version>

...snip lots of similar blocks...

  <Version>
    <Key>pacs-data/archive/2022/8/1/10/11992158/8EC0C0C4/77407295</Key>
    <Generation>1683228165974407</Generation>
    <MetaGeneration>1</MetaGeneration>
    <IsLatest>true</IsLatest>
    <LastModified>2023-05-04T19:22:45.975Z</LastModified>
    <DeletedTime>
    </DeletedTime>
    <ETag>"361b28d02accd86fef5cf92791795699"</ETag>
    <Size>243496</Size>
  </Version>
</ListBucketResult>

```

Something strange has gone on here for definite.

According to [the AWS docs](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectVersions.html), this is what the response should look like

```xml
<?xml version="1.0" encoding="UTF-8"?>
<ListVersionsResult>
   <IsTruncated>boolean</IsTruncated>
   <KeyMarker>string</KeyMarker>
   <VersionIdMarker>string</VersionIdMarker>
   <NextKeyMarker>string</NextKeyMarker>
   <NextVersionIdMarker>string</NextVersionIdMarker>
   <Version>
      <ChecksumAlgorithm>string</ChecksumAlgorithm>
      ...
      <ETag>string</ETag>
      <IsLatest>boolean</IsLatest>
      <Key>string</Key>
      <LastModified>timestamp</LastModified>
      <Owner>
         <DisplayName>string</DisplayName>
         <ID>string</ID>
      </Owner>
      <RestoreStatus>
         <IsRestoreInProgress>boolean</IsRestoreInProgress>
         <RestoreExpiryDate>timestamp</RestoreExpiryDate>
      </RestoreStatus>
      <Size>long</Size>
      <StorageClass>string</StorageClass>
      <VersionId>string</VersionId>
   </Version>
   ...
   <DeleteMarker>
      <IsLatest>boolean</IsLatest>
      <Key>string</Key>
      <LastModified>timestamp</LastModified>
      <Owner>
         <DisplayName>string</DisplayName>
         <ID>string</ID>
      </Owner>
      <VersionId>string</VersionId>
   </DeleteMarker>
   ...
   <Name>string</Name>
   <Prefix>string</Prefix>
   <Delimiter>string</Delimiter>
   <MaxKeys>integer</MaxKeys>
   <CommonPrefixes>
      <Prefix>string</Prefix>
   </CommonPrefixes>
   ...
   <EncodingType>string</EncodingType>
</ListVersionsResult>

```

In particular note that the response should be a `ListVersionsResult` but gcs has given us a `ListBucketResult`

This is why rclone is looping because it is expecting to find `NextKeyMarker` and `NextVersionIdMarker` but it isn't so it is starting the listing over again each time.

However that doesn't explain why gcs is giving us the wrong listing result.

A bit of searching finds a comment which indicates [gcs is being incompatible](https://github.com/minio/minio/discussions/15093#discussioncomment-2961551) here. There is some more [discussion on the drupal forum about this](https://www.drupal.org/project/s3fs/issues/3279662).

I can't find a defininitive statement in the GCS docs about this, but looking at [the docs for the API call](https://cloud.google.com/storage/docs/xml-api/get-bucket-list) it just doesn't look compatible with S3.

Rclone should definitely notice the response is wrong and give an error which would have saved your looping problem.

I have fixed that here:

[v1.65.0-beta.7523.15747cc9f.fix-s3-gcs-looping](https://beta.rclone.org/branch/fix-s3-gcs-looping/v1.65.0-beta.7523.15747cc9f.fix-s3-gcs-looping/) on branch [fix-s3-gcs-looping](https://github.com/rclone/rclone/tree/fix-s3-gcs-looping) (uploaded in 15-30 mins)

However I think the real problem here is that the GCS S3 interface isn't fully AWS S3 compatible. I couldn't find any [google issues](https://issuetracker.google.com/issues) about this so it would probably be worth making one if you agree with my diagnosis.

I can't make a workaround for this - the AWS S3 SDK is very inflexible unfortunately.

---

<div class="post-metadata">

**Author:** ![cberni](https://forum.rclone.org/user_avatar/forum.rclone.org/cberni/32/19689_2.png) [@cberni](https://forum.rclone.org/u/cberni)\
**Post date:** [November 21, 2023, 2:07pm UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/7 "2023-11-21T14:07:49Z")

</div>

nice!

```auto
2023/11/21 14:03:56 Failed to ls: s3 protocol error: received versions listing with IsTruncated set with no NextKeyMarker

```

by now we solved our problem using the google api... (slow and painful)

> **[Use versioned objects  |  Cloud Storage  |  Google Cloud](https://cloud.google.com/storage/docs/using-versioned-objects)**

It's not something we need to use often. In the future we can think and see how to work with versioning using the Google API.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [November 21, 2023, 4:07pm UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/8 "2023-11-21T16:07:09Z")

</div>

Glad that worked 🙂

> [@cberni](#):
>
> by now we solved our problem using the google api... (slow and painful)

Sorry rclone couldn't hack it for you this time!

Do you think it is worth reporting a Google bug about this? I guess if I do that, then at least I can link to it in the rclone docs!

I have reported lots of bugs but Google rarely seem do anything about them alas.

---

<div class="post-metadata">

**Author:** ![cberni](https://forum.rclone.org/user_avatar/forum.rclone.org/cberni/32/19689_2.png) [@cberni](https://forum.rclone.org/u/cberni)\
**Post date:** [November 21, 2023, 4:23pm UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/9 "2023-11-21T16:23:41Z")

</div>

> [@ncw](#):
>
> Sorry rclone couldn't hack it for you this time!

no problem. Thank you for the assistance!

where is the right place to report this to google? I never went back.

---

<div class="post-metadata">

**Author:** ![cberni](https://forum.rclone.org/user_avatar/forum.rclone.org/cberni/32/19689_2.png) [@cberni](https://forum.rclone.org/u/cberni)\
**Post date:** [November 21, 2023, 4:35pm UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/10 "2023-11-21T16:35:56Z")

</div>

[https://issuetracker.google.com/u/1/issues/312292516](https://issuetracker.google.com/u/1/issues/312292516)

I did it here. Not sure is the right place.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [November 23, 2023, 9:52am UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/11 "2023-11-23T09:52:43Z")

</div>

That is perfect. I added some more detail to the bug report!

I've merged this to master now which means it will be in [the latest beta](https://beta.rclone.org/) in 15-30 minutes and released in v1.65

I put a note in the docs also.

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [December 23, 2023, 9:53am UTC](https://forum.rclone.org/t/list-s3-versions-files-looping-bug/42974/12 "2023-12-23T09:53:06Z")

</div>

Closed on December 23, 2023, 9:53am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
