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

[Bug]: "Call to a member function getType() on bool" on External Storage #35364

Closed
6 of 9 tasks
cahebebe opened this issue Nov 23, 2022 · 4 comments · Fixed by nextcloud/documentation#10603
Closed
6 of 9 tasks
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback bug

Comments

@cahebebe
Copy link

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

When I try to store a file in a External storage y got a error message "Call to a member function getType() on bool", I've tried in diferent locations inside it and I got the same message, also in the Nextcloud Client for Windows shows an error too.

Steps to reproduce

  1. Go to External Storage
  2. Choose a folder
  3. Drag and drop a file from Desktop to the Nextcloud page
  4. The error message is shown.

Expected behavior

Should upload and show the uploaded file.

Installation method

Community VM appliance

Operating system

RHEL/CentOS

PHP engine version

PHP 7.4

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Updated to a major version (ex. 22.2.3 to 23.0.1)

Are you using the Nextcloud Server Encryption module?

No response

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "storage.procesamos.net"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "25.0.1.1",
        "overwrite.cli.url": "https:\/\/storage.procesamos.net",
        "overwriteprotocol": "https",
        "forcessl": true,
        "forceSSLforSubdomains": true,
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "default_phone_region": "CO",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "maintenance": false,
        "enable_previews": false,
        "theme": "",
        "loglevel": 2,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "sendmail",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

Enabled:
  - activity: 2.17.0
  - bruteforcesettings: 2.5.0
  - circles: 25.0.0
  - cloud_federation_api: 1.8.0
  - comments: 1.15.0
  - dav: 1.24.0
  - federatedfilesharing: 1.15.0
  - federation: 1.15.0
  - files: 1.20.1
  - files_external: 1.17.0
  - files_pdfviewer: 2.6.0
  - files_rightclick: 1.4.0
  - files_sharing: 1.17.0
  - files_trashbin: 1.15.0
  - files_versions: 1.18.0
  - firstrunwizard: 2.14.0
  - logreader: 2.10.0
  - lookup_server_connector: 1.13.0
  - nextcloud_announcements: 1.14.0
  - notifications: 2.13.1
  - oauth2: 1.13.0
  - password_policy: 1.15.0
  - privacy: 1.9.0
  - provisioning_api: 1.15.0
  - recommendations: 1.4.0
  - related_resources: 1.0.3
  - serverinfo: 1.15.0
  - settings: 1.7.0
  - sharebymail: 1.15.0
  - support: 1.8.0
  - survey_client: 1.13.0
  - systemtags: 1.15.0
  - text: 3.6.0
  - theming: 2.0.1
  - twofactor_backupcodes: 1.14.0
  - updatenotification: 1.15.0
  - user_status: 1.5.0
  - viewer: 1.9.0
  - workflowengine: 2.7.0
Disabled:
  - admin_audit
  - calendar: 3.5.2
  - checksum: 1.1.5
  - contacts: 4.2.2
  - contactsinteraction: 1.3.0
  - dashboard: 7.2.0
  - deck: 1.7.2
  - duplicatefinder: 0.0.15
  - encryption
  - forms: 2.5.1
  - mail: 1.14.3
  - maps: 0.2.1
  - phonetrack: 0.7.2
  - photos: 1.4.0
  - richdocuments: 6.3.1
  - spreed: 14.0.6
  - suspicious_login
  - talked: 0.4.0
  - twofactor_totp
  - user_ldap
  - weather_status: 1.2.0
  - workflow_pdf_converter: 1.9.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{"reqId":"Y34k6@@ESPR-EJJkLx5suwAAAAw","level":3,"time":"2022-11-23T13:49:31+00:00","remoteAddr":"xxx.xxx.xxx.xxx","user":"xxxxxxxx","app":"webdav","method":"PUT","url":"/remote.php/webdav/PlazoLargo/BackupAngie/Foto1.png","message":"Call to a member function getType() on bool","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0","version":"25.0.1.1","exception":{"Exception":"Error","Message":"Call to a member function getType() on bool","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/File.php","line":401,"function":"refreshInfo","class":"OCA\\DAV\\Connector\\Sabre\\Node","type":"->"},{"file":"/var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":151,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1098,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":504,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/html/nextcloud/apps/dav/appinfo/v1/webdav.php","line":85,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/html/nextcloud/remote.php","line":171,"args":["/var/www/html/nextcloud/apps/dav/appinfo/v1/webdav.php"],"function":"require_once"}],"File":"/var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/Node.php","Line":115,"message":"Call to a member function getType() on bool","exception":{},"CustomMessage":"Call to a member function getType() on bool"}}

Additional info

No response

@cahebebe cahebebe added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Nov 23, 2022
@cahebebe cahebebe changed the title [Bug]: [Bug]: "Call to a member function getType() on bool" on External Storage Nov 23, 2022
@fmenabe
Copy link
Contributor

fmenabe commented Jan 10, 2023

I encounter this error while making this PR #36075 to support s3 storage classes. When setting an invalid storage class, the file is not created. Instead of catching and showing the storage error, the actual code try to refresh the information of the newly created file, which was not created ...

The error happen in this short code (apps/dav/lib/Connector/Sabre/Node.php):

112     protected function refreshInfo() {                                                                                                                                                                        
113         $this->info = $this->fileView->getFileInfo($this->path);                                                                                                                                              
114         $root = \OC::$server->get(IRootFolder::class);                                                                                                                                                        
115         if ($this->info->getType() === FileInfo::TYPE_FOLDER) {} }                                                                                                                                            

At line 115, $this->info->getType() is called, being the result of $this->fileView->getFileInfo($this->path). The lib/private/Files/View.php:getFileInfo()
return the boolean false if there is an error - which is the case as the file does not exists - and so generate the error we see (as it should return an object).

The low level storage error should be catched and displayed instead of trying to refresh informations of a file that was not created.

@cahebebe, in my case there was a previous log from the objectstore indicating the error and I suppose you have some misconfiguration or another bug in there.

@cahebebe
Copy link
Author

Changing the log level I found the following issues and mistakes:

  1. The GCS bucket name has a underscore "_" character in (aws/aws-sdk-php/src/S3/S3Client.php) in 3rdparty repository PR 1289 and the regular expression doesn't have it.
    return ($bucketLen >= 3 && $bucketLen <= 63) && // Cannot look like an IP address !filter_var($bucket, FILTER_VALIDATE_IP) && preg_match('/^[a-z0-9]([a-z0-9\-\.\_]*[a-z0-9])?$/', $bucket);

  2. The level access in GCS in the bucket changed from fine-grained to uniform generating an error message when execute PutObject:
    "Cannot insert legacy ACL for an object when uniform bucket-level access is enabled. Read more at https://cloud.google.com/storage/docs/uniform-bucket-level-access"
    This occurs when a bucket is created selecting uniform and automatically GCS locks it 90 days after created or assigned, it's recommendable set or change it to fine-grained to prevent it in the future.

Thanks @fmenabe for the recommendations.

joshtrichards added a commit to joshtrichards/nc-documentation that referenced this issue Jun 10, 2023
Fixes nextcloud/server#35364

Also adds note about S3 endpoint naming to make consistent with Primary Storage change made in nextcloud#10595

Signed-off-by: Josh Richards <[email protected]>
joshtrichards added a commit to joshtrichards/nc-documentation that referenced this issue Jun 10, 2023
Fixes nextcloud/server#35364

Also adds note about S3 endpoint naming to to External Storage make consistent with Primary Storage change made in nextcloud#10595

Signed-off-by: Josh Richards <[email protected]>
@joshtrichards
Copy link
Member

Fixed in #36120 (during some other clean-up) and released in NC26.
Docs being addressed in nextcloud/documentation#10603 (addressing the bucket naming requirements)

@cahebebe Since NC uses aws-sdk-php to access S3 object stores, even 3rd-party S3 object stores have to be used in a way that is compliant with AWS S3. AWS doesn't generally accept patches for compatibility with third-party S3 platforms that aren't 100% compliant with AWS S3. Many years ago AWS S3 supported underscores, but has not for at least 5 years. Even the Google doc you cited in your PR discourages the use of underscores (in the "considerations" section) because they aren't valid DNS hostnames. It would not surprise me in the least if Google dropped support for underscores at some point as well. I'd say don't use the underscore. :-)

I'll add a note to the doc sections for both External Storage and Primary Storage for S3 that bucket names must be AWS S3 compliant regardless of one's S3 provider/platform.

@joshtrichards
Copy link
Member

Additional follow-up: That's a good catch @cahebebe regarding ACL vs Uniform. At that link Google is a bit vague about it, but does says it's required if using the XML API (which is, effectively, the S3 compatibility API). Google references it here a bit more explicitly finally mentioning S3: https://cloud.google.com/storage/docs/access-control/lists

You most likely want to use ACLs in the following cases:

  • You need to customize access to individual objects within a bucket. ACLs can be set for individual objects, while IAM permissions can only be granted at the bucket level or higher.
  • You are exclusively using the XML API or require interoperability with Amazon S3.

I hadn't seen that before. I really wish Google documented all their S3 caveats in a bit more centralized manner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants