deck icon indicating copy to clipboard operation
deck copied to clipboard

Can't archive board via deck API

Open shahar3000 opened this issue 2 years ago • 1 comments

Describe the bug I am trying to archive a board using the deck API but no matter how I pass the archived field, I get archived must be a boolean exception. Looking at the source code I see that the input is validated by is_bool($archived) === false (reference) So I am wondering, given that the http request translates everything to string, is there any valid string here? In boards/{board_id}/acl POST API I was able to use 0|1 to disable/enable the sharing (edit/share/manage) so perhaps the input validation of board update should be similar to the sharing API or maybe try to cast the value, e.g.:

filter_var(<api_val>, FILTER_VALIDATE_BOOLEAN);

To Reproduce Run a curl command on an existing board you wish to archive:

curl -u <user>:<password> PUT -H "OCS-APIRequest: true" -H "Content-Type: application/json" "https://<host>/index.php/apps/deck/api/v1.1/boards/<board_id>?color=<new_board_color>&title=<new_board_title>&archived=True"

Expected behavior The given board should be archived.

Server details

Operating system:

Web server: Apache/2.4.53 (Debian) (apache2handler)

Database: mysql 10.7.3

PHP version: 8.0.18

Nextcloud version: (see Nextcloud admin page) 24.0.0 - 24.0.0.12

Where did you install Nextcloud from: unknown (Nextcloud container)

Signing status:

No errors have been found.

List of activated apps:

Enabled:
  - accessibility: 1.10.0
  - activity: 2.16.0
  - admin_audit: 1.14.0
  - approval: 1.0.9
  - calendar: 3.3.2
  - circles: 24.0.0
  - cloud_federation_api: 1.7.0
  - comments: 1.14.0
  - contacts: 4.1.1
  - contactsinteraction: 1.5.0
  - dashboard: 7.4.0
  - dav: 1.22.0
  - deck: 1.7.1
  - event_update_notification: 1.5.0
  - federatedfilesharing: 1.14.0
  - federation: 1.14.0
  - files: 1.19.0
  - files_accesscontrol: 1.14.0
  - files_automatedtagging: 1.14.0
  - files_external: 1.16.1
  - files_markdown: 2.3.6
  - files_mindmap: 0.0.26
  - files_pdfviewer: 2.5.0
  - files_retention: 1.13.1
  - files_rightclick: 1.3.0
  - files_sharing: 1.16.2
  - files_trashbin: 1.14.0
  - files_versions: 1.17.0
  - files_videoplayer: 1.13.0
  - firstrunwizard: 2.13.0
  - groupfolders: 12.0.0
  - impersonate: 1.11.0
  - logreader: 2.9.0
  - lookup_server_connector: 1.12.0
  - nextcloud_announcements: 1.13.0
  - notifications: 2.12.0
  - oauth2: 1.12.0
  - password_policy: 1.14.0
  - provisioning_api: 1.14.0
  - quicknotes: 0.8.0
  - recommendations: 1.3.0
  - richdocuments: 6.1.0
  - serverinfo: 1.14.0
  - settings: 1.6.0
  - sharebymail: 1.14.0
  - socialsharing_email: 2.5.0
  - spreed: 14.0.2
  - support: 1.7.0
  - survey_client: 1.12.0
  - systemtags: 1.14.0
  - tables: 0.1.2
  - text: 3.5.1
  - theming: 1.15.0
  - twofactor_backupcodes: 1.13.0
  - twofactor_duo: 0.0.2
  - twofactor_email: 2.4.0
  - twofactor_totp: 6.4.0
  - updatenotification: 1.14.0
  - user_ldap: 1.14.1
  - user_status: 1.4.0
  - viewer: 1.8.0
  - workflow_script: 1.8.0
  - workflowengine: 2.6.0
Disabled:
  - encryption
  - photos: 1.6.0
  - privacy: 1.8.0
  - weather_status: 1.4.0

Nextcloud configuration:

{ 
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "mail_smtpmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpsecure": "tls",
        "mail_smtpauth": true,
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "***REMOVED SENSITIVE VALUE***"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "24.0.0.12",
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "overwritehost": "***REMOVED SENSITIVE VALUE***",
        "overwriteprotocol": "https",
        "overwritewebroot": "\/",
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "force_language": "***REMOVED SENSITIVE VALUE***",
        "default_locale": "***REMOVED SENSITIVE VALUE***",
        "skeletondirectory": "",
        "lost_password_link": "disabled",
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "twofactor_duo": {
            "IKEY": "***REMOVED SENSITIVE VALUE***",
            "SKEY": "***REMOVED SENSITIVE VALUE***",
            "HOST": "***REMOVED SENSITIVE VALUE***",
            "AKEY": "***REMOVED SENSITIVE VALUE***"
        },
        "maintenance": false,
        "log_rotate_size": "10485760",
        "share_folder": "Shared",
        "app_install_overwrite": [
            "workflow_script"
        ]
    }
}

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

shahar3000 avatar Jun 19 '22 13:06 shahar3000

A temporary fix that seems to solve the issue:

diff --git a/lib/Service/BoardService.php b/lib/Service/BoardService.php
index b6e749f6..235d21c3 100644
--- a/lib/Service/BoardService.php
+++ b/lib/Service/BoardService.php
@@ -438,7 +438,8 @@ class BoardService {
                        throw new BadRequestException('color must be provided');
                }
 
-               if (is_bool($archived) === false) {
+               $tmp = filter_var($archived, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
+               if ($tmp === NULL) {
                        throw new BadRequestException('archived must be a boolean');
                }
 
@@ -447,7 +448,7 @@ class BoardService {
                $changes = new ChangeSet($board);
                $board->setTitle($title);
                $board->setColor($color);
-               $board->setArchived($archived);
+               $board->setArchived($tmp);
                $changes->setAfter($board);
                $this->boardMapper->update($board); // operate on clone so we can check for updated fields
                $this->boardMapper->mapOwner($board);

shahar3000 avatar Jun 19 '22 14:06 shahar3000