Skip to content

occ files_external:create fails with Oracle #39650

Closed

Description

@phil-davis

https://drone.owncloud.com/owncloud/core/34154/122/18

runsh: Total unexpected failed scenarios throughout the test run:
cliExternalStorage/filesExternalWebdavOwncloud.feature:15
cliExternalStorage/filesExternalWebdavOwncloud.feature:32
cliExternalStorage/filesExternalWebdavOwncloud.feature:66
cliExternalStorage/filesExternalWebdavOwncloud.feature:85
cliExternalStorage/filesExternalWebdavOwncloud.feature:106
cliExternalStorage/filesExternalWebdavOwncloud.feature:127
cliExternalStorage/filesExternalWebdavOwncloud.feature:149
cliExternalStorage/filesExternalWebdavOwncloud.feature:172
cliExternalStorage/filesExternalWebdavOwncloud.feature:193
cliExternalStorage/filesExternalWebdavOwncloud.feature:209
cliExternalStorage/filesExternalWebdavOwncloud.feature:229
  Scenario: creating a webdav_owncloud external storage                                                                              # /drone/src/tests/acceptance/features/cliExternalStorage/filesExternalWebdavOwncloud.feature:15
    When the administrator creates an external mount point with the following configuration about user "Alice" using the occ command # OccContext::createExternalMountPointUsingTheOccCommand()
      | host                   | %remote_server%    |
      | root                   | TestMnt            |
      | secure                 | false              |
      | user                   | %username%         |
      | password               | %password%         |
      | storage_backend        | owncloud           |
      | mount_point            | TestMountPoint     |
      | authentication_backend | password::password |
    And the administrator verifies the mount configuration for local storage "TestMountPoint" using the occ command                  # OccContext::theAdministratorVerifiesTheMountConfigurationForLocalStorageUsingTheOccCommand()
    Then the following mount configuration information should be listed:                                                             # OccContext::theFollowingInformationShouldBeListed()
      | status | code | message |
      | ok     | 0    |         |
      OccContext::theFollowingInformationShouldBeListed 'ok, 0, ' was expected to be listed, but is not listed in the mount configuration information
      Failed asserting that two arrays are equal.
      --- Expected
      +++ Actual
      @@ @@
       Array (
      -    'status' => 'ok'
      -    'code' => '0'
      -    'message' => ''
      +    'status' => 'error'
      +    'code' => '1'
      +    'message' => 'InvalidArgumentException'
       )
    And as "admin" folder "TestMountPoint" should exist                                                                              # FeatureContext::asFileOrFolderShouldExist()

  @skipOnEncryption @issue-encryption-181 @skipOnDbOracle @issue-38165
  Scenario: using webdav_owncloud as external storage                                                                                     # /drone/src/tests/acceptance/features/cliExternalStorage/filesExternalWebdavOwncloud.feature:32
    Given the administrator has created an external mount point with the following configuration about user "Alice" using the occ command # OccContext::adminHasCreatedAnExternalMountPointWithFollowingConfigUsingTheOccCommand()
      | host                   | %remote_server%    |
      | root                   | TestMnt            |
      | secure                 | false              |
      | user                   | %username%         |
      | password               | %password%         |
      | storage_backend        | owncloud           |
      | mount_point            | TestMountPoint     |
      | authentication_backend | password::password |
      The command was not successful, exit code was 1.
      stdOut was: ''
      stdErr was: '
      In AbstractOracleDriver.php line 61:

        An exception occurred while executing 'INSERT INTO "oc_external_config" ("m  
        ount_id","key","value") SELECT ?,?,? FROM "oc_external_config" WHERE "mount  
        _id" = ? AND "key" = ? HAVING COUNT(*) = 0' with params [2, "secure", false  
        , 2, "secure"]:                                                              

        ORA-01400: cannot insert NULL into ("AUTOTEST"."oc_external_config"."value")                                                                            

      In OCI8Exception.php line 25:

        ORA-01400: cannot insert NULL into ("AUTOTEST"."oc_external_config"."value")                                                                            

      files_external:create [--user [USER]] [-c|--config CONFIG] [--dry] [--output [OUTPUT]] [--] <mount_point> <storage_backend> <authentication_backend>
      '
       (Exception)

Activity

  1. phil-davis commented on Jan 7, 2022

    @phil-davis
    ContributorAuthor

    PR #39637 demonstrates the issue.

    The first few scenarios have been in the test suite for some time. They were added by PR #36857 which was merged 2020-02-18. And PR #37025 was run on 2020-02-27 and those passed on Oracle. So I think that this passed previously.

    Needs investigation...

  2. DeepDiver1975 commented on Jun 23, 2026

    @DeepDiver1975
    Contributor

    🤖 Automated issue triage by Claude Code review agent.

    Confirmed bug — root cause located. A boolean-typed external-storage config value (e.g. secure=false) is persisted as a PHP bool false, which the OCI8 driver binds as NULL, violating the NOT NULL constraint on the oc_external_config.value column. The exact failing query and params from the issue confirm this:

    INSERT INTO "oc_external_config" ("mount_id","key","value") SELECT ?,?,? ...
      with params [2, "secure", false, 2, "secure"]
    ORA-01400: cannot insert NULL into ("AUTOTEST"."oc_external_config"."value")
    

    Trace

    1. apps/files_external/lib/Command/Create.php (~line 154-166) parses key=value config from the CLI as strings and calls $mount->setBackendOptions($config).
    2. lib/public/Files/External/DefinitionParameter.php::validateValue() (lines 188-211) coerces values of VALUE_BOOLEAN parameters — secure is one — from the string 'false' to a PHP boolean false:
      case self::VALUE_BOOLEAN:
          ...
          case 'false':
              $value = false;
    3. lib/private/Files/External/Service/StoragesService.php::addStorage() (lines 284-287) iterates getBackendOptions() and passes each value unchanged to $this->dbConfig->setConfig($configId, $key, $value).
    4. lib/private/Files/External/Service/DBConfigService.php::setConfig() (lines 272-277) passes the raw false straight into insertIfNotExist('*PREFIX*external_config', ['mount_id'=>..., 'key'=>..., 'value'=>$value], ...).
    5. lib/private/DB/Adapter.php::insertIfNotExist() binds array_values($input) — including the boolean false — as the value parameter. On Oracle (OCI8), DBAL binds PHP false such that it lands as NULL/empty, and Oracle rejects it because the column is NOT NULL.

    Why it is Oracle-specific

    The value column is defined as string, notnull => true in core/Migrations/Version20170111103310.php. On MySQL/Postgres/SQLite a bound false becomes '' or 0 and the NOT NULL check passes; on Oracle an empty bind is treated as NULL, so ORA-01400 fires. That is also why this regressed after passing on Oracle in early 2020 (per @phil-davis) — the failure surfaces only once a boolean-typed option (secure) reaches the bind layer as a real bool.

    Suggested fix

    Normalize the value to a string before persistence so no boolean ever reaches the bind layer — cast in DBConfigService::setConfig() (e.g. value => (string)$value, mapping false→'0' / true→'1'), and/or have DefinitionParameter::validateValue() keep the value as '0'/'1' instead of a PHP bool. Casting at the DB-service boundary is the most robust spot since setOption() already json_encodes its value for the same reason. Note setConfig()'s UPDATE branch already uses IQueryBuilder::PARAM_STR, so only the INSERT path is inconsistent.

    (No fix PR is being opened: owncloud/core is excluded from automated fix fleets.)

  3. phil-davis commented on Jun 23, 2026

    @phil-davis
    ContributorAuthor

    Oracle support is being dropped for oC11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions