Skip to content

shareAccessByID.feature return codes for invalid shares are different with Oracle and Postgresql #39651

Closed

Description

@phil-davis

https://drone.owncloud.com/owncloud/core/34154/70/13

runsh: Total unexpected failed scenarios throughout the test run:
apiShareOperationsToShares2/shareAccessByID.feature:50
apiShareOperationsToShares2/shareAccessByID.feature:51
apiShareOperationsToShares2/shareAccessByID.feature:52
apiShareOperationsToShares2/shareAccessByID.feature:53
  Scenario Outline: Get a share with an invalid share id                    # /drone/src/tests/acceptance/features/apiShareOperationsToShares2/shareAccessByID.feature:40
    Given using OCS API version "<ocs_api_version>"                         # FeatureContext::usingOcsApiVersion()
    When user "Alice" gets share with id "<share_id>" using the sharing API # FeatureContext::userGetsTheLastShareWithTheShareIdUsingTheSharingApi()
    Then the OCS status code should be "404"                                # OCSContext::theOCSStatusCodeShouldBe()
    And the HTTP status code should be "<http_status_code>"                 # FeatureContext::thenTheHTTPStatusCodeShouldBe()
    And the API should not return any data                                  # FeatureContext::theApiShouldNotReturnAnyData()

    Examples:
      | ocs_api_version | share_id   | http_status_code |
      | 1               | 2333311    | 200              |
      | 2               | 2333311    | 404              |
      | 1               | helloshare | 200              |
        OCS status code is not any of the expected values 404 got 996
        Failed asserting that an array contains '996'.
      | 2               | helloshare | 404              |
        OCS status code is not any of the expected values 404 got 500
        Failed asserting that an array contains '500'.
      | 1               | $#@r3      | 200              |
        OCS status code is not any of the expected values 404 got 996
        Failed asserting that an array contains '996'.
      | 2               | $#@r3      | 404              |
        OCS status code is not any of the expected values 404 got 500
        Failed asserting that an array contains '500'.
      | 1               | 0          | 200              |
      | 2               | 0          | 404              |

Activity

  1. phil-davis commented on Jan 7, 2022

    @phil-davis
    ContributorAuthor

    Other tests for accessing share by valid share id are passing. So the happy-path is OK.

    When trying to access an invalid/non-existent share id, with MariaDb/MySQL, we get the expected 404 "not found". But with Oracle we get various 996 and 500 codes. So something different is going wrong in this case.

  2. phil-davis commented on Jan 7, 2022

    @phil-davis
    ContributorAuthor

    PR #39637 demonstrates the failure.

  3. changed the title [-]shareAccessByID.feature return codes for invalid shares are different with Oracle[/-] [+]shareAccessByID.feature return codes for invalid shares are different with Oracle and Postgresql[/+] on Jan 7, 2022
  4. phil-davis commented on Feb 7, 2022

    @phil-davis
    ContributorAuthor

    This still happens, see #39755 (comment)

  5. DeepDiver1975 commented on Jun 23, 2026

    @DeepDiver1975
    Contributor

    🤖 Automated issue triage by Claude Code review agent.

    This looks fixed — closing as resolved.

    The reported failure was that apiShareOperationsToShares2/shareAccessByID.feature ("Get a share with an invalid share id") returned OCS 996 / HTTP 500 instead of 404 on Oracle and PostgreSQL for non-numeric share IDs such as helloshare and $#@r3. The numeric-but-nonexistent IDs (2333311, 0) already returned 404 everywhere; only the non-numeric values blew up, because the string was passed into a query against the integer share.id column and Oracle/Postgres raise an invalid input syntax for type integer DB error (caught generically → 996/500), whereas MySQL/MariaDB silently match no rows → ShareNotFound → 404.

    This root cause was fixed by PR #39873 ("throw ShareNotFound when share id is not an integer", merged 2022-03-14, commit 8705f94), which adds a ctype_digit() guard to both share providers so a non-integer id throws ShareNotFound before touching the database:

    • lib/private/Share20/DefaultShareProvider.php – getShareById()
    • apps/federatedfilesharing/lib/FederatedShareProvider.php – getShareById()
    if (\!ctype_digit((string)$id)) {
        // share id is defined as a field of type integer ...
        // depending on the database, the query may throw an exception
        // with a message like "invalid input syntax for type integer"
        // So throw ShareNotFound now.
        throw new ShareNotFound();
    }

    ShareNotFound is mapped to a 404 in Share20OcsController::getShare(), so invalid/non-numeric share IDs now consistently return OCS 404 across all databases — matching the feature expectations, which still assert 404 and currently carry no skip/expected-failure entry.

    If this still reproduces on a current release, please reopen with a fresh CI link and DB details — thank you!

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