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

Potential issue - S3 External Storage Error: fclose(): supplied resource is not a valid stream resource #15486

Closed
mlshapiro opened this issue May 9, 2019 · 9 comments · Fixed by #17616
Labels
1. to develop Accepted and waiting to be taken care of bug

Comments

@mlshapiro
Copy link

Steps to reproduce

  1. Enable S3 External storage with default options, except:
  • Disable default option "Enable Encryption"
  • NOTE: I am using an S3 compliant API (wasabi) not an actual S3 bucket
  1. Add file to the external storage directory either from the desktop app or the browser client

Expected behaviour

The file should be added to the bucket in the external storage without issues.

Actual behaviour

The file is added successfully to the bucket and syncs correctly. While the file is added, it throws a log message:

Error    PHP    fclose(): supplied resource is not a valid stream resource at /snap/nextcloud/13144/htdocs/apps/files_external/lib/Lib/Storage/AmazonS3.php#641

Server configuration

Operating system: Ubuntu 18.04

Web server: Apache 2.4

Database: MySQL 5.7, Redis 4.0

PHP version: PHP 7.2

Nextcloud version: 15.0.7

Updated from an older Nextcloud/ownCloud or fresh install:

Where did you install Nextcloud from: nextcloud-snap

Signing status:

Signing status
Login as admin user into your Nextcloud and access 
http://example.com/index.php/settings/integrity/failed 

No errors have been found.

List of activated apps:

App list
If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your Nextcloud installation folder

Nextcloud configuration:

Config report

No extra configuration beyond snap defaults.

Are you using external storage, if yes which one: yes, Wasabi (via Amazon S3 API)

Are you using encryption: yes for the local server. No for the external storage

Are you using an external user-backend, if yes which one: No

Logs

Web server error log

Web server error log
Not accessible

Nextcloud log (data/nextcloud.log)

Nextcloud log
Error | PHP | fclose():  supplied resource is not a valid stream resource at  /snap/nextcloud/13144/htdocs/apps/files_external/lib/Lib/Storage/AmazonS3.php#641
-- | -- | --
@mlshapiro mlshapiro added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels May 9, 2019
@baskraai
Copy link

Have the same issue with a full Amazon S3 backed Nextcloud instance running 16.0.0. It's running inside the official Docker container from Nextcloud. Files have size 0 when uploaded through the web interface. When uploaded through the client the file shows up with the right size and readable from other devices and the web interface. (Tested with text file and foto PNG)

@craysiii
Copy link

Also experiencing the same issue. Wasabi backend. Windows client. Running NC 16 installed manually.

@beanaroo
Copy link

Experiencing the same issue on NC 16 with S3 bucket added as external storage

@neomed
Copy link

neomed commented Jul 10, 2019

Experiencing the same issue on NC 16.0.2 with S3 bucket added as external storage

@goldo
Copy link

goldo commented Aug 4, 2019

same issue with same v16 inside a docker with a wasabi/s3 sotage

@kesselb
Copy link
Contributor

kesselb commented Aug 11, 2019

Could be a regression from #14210

$this->writeObject($path, $source);
$this->invalidateCache($path);
fclose($source);

Starting with the referenced pull request the stream is closed in writeObject.

Index: apps/files_external/lib/Lib/Storage/AmazonS3.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- apps/files_external/lib/Lib/Storage/AmazonS3.php	(revision 7b8ddd7e958bfbf7dbddf38aca2c789310e3d1a4)
+++ apps/files_external/lib/Lib/Storage/AmazonS3.php	(date 1565546526475)
@@ -638,7 +638,6 @@
 			$source = fopen($tmpFile, 'r');
 			$this->writeObject($path, $source);
 			$this->invalidateCache($path);
-			fclose($source);
 
 			unlink($tmpFile);
 			return true;

A) Remove fclose($source) or B) feof before fclose($source)

cc @rullzer @icewind1991

@kesselb kesselb added 1. to develop Accepted and waiting to be taken care of and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Aug 11, 2019
@jasonkuehl
Copy link

Seeing this as well with 16.0.3

@solracsf
Copy link
Member

solracsf commented Oct 6, 2020

Observing the same beahviour on 19.0.3 @kesselb

"fclose(): supplied resource is not a valid stream resource at /lib/private/Files/ObjectStore/S3ObjectTrait.php#107"

@kesselb
Copy link
Contributor

kesselb commented Oct 6, 2020

Please create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants