← 输入框|github.com|刷新
Skip to content

Failure on long lines in expectations #1397

Done

Description

@jgebal

Describe the bug

When the expectation text is long, the framework fails to process it correctly and there is a buffer overflow of 4000 chars that is causing the test to finish with an error instead of reporting a failure.

Provide version info
Information about utPLSQL and Database version,

utPLSQL v.3.2.3.4508
DB: 19.20
OS: x86_64/Linux 2.4.xx

To Reproduce

create or replace package test_package1 is
  --%suite

  --%test
  procedure sp_test;
end;
/
create or replace package body test_package1 is
  procedure sp_test is
  begin
    ut.expect(1, 'message').to_equal(2); /*3999 chars of comment *****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
  end;
end;
/
begin
    ut.run('test_package1');
end;

This causes a test finishing with framework exception:

test_package1
  sp_test [,005 sec] (FAILED - 1)

Failures:

  1) sp_test
      ORA-06502: PL/SQL: numeric or value error: character string buffer too small
      ORA-06512: at "UT3.UT_EXPECTATION_PROCESSOR", line 194
      ORA-06512: at "UT3.UT_EXPECTATION_RESULT", line 29
      ORA-06512: at "UT3.UT_EXPECTATION_BASE", line 30
      ORA-06512: at "UT3.UT_EXPECTATION", line 118
      ORA-06512: at "PMUSER.TEST_PACKAGE1", line 4
      ORA-06512: at "UT3.UT_EXPECTATION_PROCESSOR", line 194
      ORA-06512: at "UT3.UT_EXPECTATION_RESULT", line 29
      ORA-06512: at "UT3.UT_EXPECTATION_BASE", line 30
      ORA-06512: at "UT3.UT_EXPECTATION", line 118
      ORA-06512: at "PMUSER.TEST_PACKAGE1", line 4
      ORA-06512: at line 7
Finished in ,0072 seconds
1 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s)

Expected behavior
The framework should handle correctly long lines in and around expectations.
It could for example show first 500 chars of the failing line to prevent the overflow.

test_package1
  sp_test [,005 sec] (FAILED - 1)

Failures:

  1) sp_test
      "message"
      Actual: 1 (number) was expected to equal: 2 (number)
      at "PMUSER.TEST_PACKAGE1.SP_TEST", line 4 ut.expect(1, 'message').to_equal(2); /*3999 chars of comment *******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************

Finished in ,007418 seconds
1 tests, 1 failed, 0 errored, 0 disabled, 0 warning(s)

Activity

  1. jgebal commented on Nov 19, 2026

    @jgebal
    MemberAuthor

    This issue is related to #1396 and to problems that are getting fixed in in PR #1394

  2. vasipallyn commented on Nov 25, 2026

    @vasipallyn
    Contributor

    Hi @jgebal, I'd like to work on this one.

    The overflow comes from ut_expectation_processor.who_called_expectation: the caller line, the source line returned by ut_metadata.get_source_definition_line and the remaining call stack are concatenated into l_result varchar2(4000), so a source line close to 4000 bytes overflows it.

    Proposed fix:

    1. Truncate the source text shown after at "...", line N to the first 500 characters (with a ... marker when cut), as suggested in the issue.
    2. Make sure the assembled caller info can never exceed 4000 bytes, so a long call stack can't hit the same error.

    I'd keep this independent of #1394/#1396 (how a source line split across rows in all_source is read and numbered), so the two changes don't overlap.

    Tests: a case in test_expectation_processor that creates a package with a line over 4000 bytes next to the expectation and checks that the test fails (not errors) with a truncated source line, plus a case for a long call stack.

    Does 500 characters work for you, and is it OK to keep this separate from #1394?

  3. jgebal commented on Nov 26, 2026

    @jgebal
    MemberAuthor

    Hi @vasipallyn

    Thank you for your interest in contributing to the codebase.
    Feel free to give it a go.

    The fix should be done outside of #1394 and there should be no conflicts. This is why I created 2 separate issues to track those bugs.

  4. added a commit that references this issue on Dec 2, 2026
    881ecd9
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