Project

General

Profile

Bug #10284

JSON import error handing improvement

Added by Teodor Gorghe about 1 year ago. Updated 12 months ago.

Status:
Test
Priority:
Normal
Assignee:
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
production:
No
env_name:
topics:

Related issues

Related to Base Language - Bug #10381: READ-JSON dataset handle method doesn't throw error when parsing a invalid JSON Test

History

#1 Updated by Teodor Gorghe about 1 year ago

Suppose we have this unit test, which checks the JSON error message on import:
  • ABL Code:
    USING OpenEdge.Core.Assert FROM PROPATH.
    USING support.test.AssertExt FROM PROPATH.
    
    BLOCK-LEVEL ON ERROR UNDO, THROW.
    
    CLASS tests.TestInvalidJSON:
        DEFINE VARIABLE hDSet       AS HANDLE    NO-UNDO.
    
        @Test.
        METHOD PUBLIC VOID TestInvalidJsonDataset():
            DEFINE VARIABLE lRetOk AS LOGICAL NO-UNDO.
            DEFINE VARIABLE clongchar AS LONGCHAR NO-UNDO.
            clongchar = "Invalid text".
            CREATE DATASET  hDSet.
            hDSet:READ-JSON ("longchar", clongchar, "empty") NO-ERROR.
            Assert:Equals(1, ERROR-STATUS:NUM-MESSAGES).
            AssertExt:Error(15358, "Error parsing JSON: expected bracket, but found I. (15358)").
        END METHOD.
    END CLASS.
    

This passes on OE 4GL, but fails on FWD:

╷
├─ JUnit Jupiter ✔
├─ JUnit Vintage ✔
├─ JUnit Platform Suite ✔
└─ FWD Test ✔
   └─ tests.TestInvalidJSON ✔
      └─ testInvalidJsonDataset ✘ Expected: 1 but was: 0

Failures (1):
  FWD Test:tests.TestInvalidJSON:testInvalidJsonDataset
    MethodSource [className = 'com.goldencode.testcases.tests.TestInvalidJson', methodName = 'testInvalidJsonDataset', methodParameterTypes = '']
    => org.opentest4j.AssertionFailedError: Expected: 1 but was: 0
       com.goldencode.p2j.oo.core.AbstractAssert.raiseErrorForEquals(AbstractAssert.java:2182)
       com.goldencode.p2j.oo.core.AbstractAssert.call(AbstractAssert.java:1778)
       com.goldencode.p2j.oo.core.AbstractAssert.call(AbstractAssert.java:1762)
       com.goldencode.p2j.oo.core.AbstractAssert.call(AbstractAssert.java:2288)
       com.goldencode.p2j.oo.core.AbstractAssert.equalsImpl(AbstractAssert.java:1775)
       com.goldencode.p2j.oo.core.Assert.legacyEquals(Assert.java:2502)
       com.goldencode.testcases.tests.TestInvalidJson.testInvalidJsonDataset(TestInvalidJson.java:52)
       com.goldencode.testcases.tests.TestInvalidJson.testInvalidJsonDataset(TestInvalidJson.java:47)

#3 Updated by Teodor Gorghe about 1 year ago

This issue is also happening for static datasets and temp-table.

#4 Updated by Teodor Gorghe about 1 year ago

  • Status changed from New to WIP

Created task branch 10284a.

#5 Updated by Teodor Gorghe about 1 year ago

  • Status changed from WIP to Review
  • Assignee set to Teodor Gorghe
  • reviewer Constantin Asofiei added

Committed revision 16039 on task branch 10284a:
- READ-JSON error handling improvement.

#6 Updated by Teodor Gorghe about 1 year ago

  • % Done changed from 0 to 100

#7 Updated by Teodor Gorghe about 1 year ago

  • Status changed from Review to WIP
  • % Done changed from 100 to 50

#8 Updated by Constantin Asofiei about 1 year ago

Please add protection if the i.e. indexOf finds a char (is not negative), in all code which checks 'indexOf'.

#9 Updated by Teodor Gorghe about 1 year ago

Regarding for this task, I did changed from 100 to 50 percent because there are more cases when this message is checked on some tests.
Then, I have noticed that 4GL and the Jackson JSON parser throws JSON error at different locations, on more invalid JSON payloads. I don't have a solution for that just yet, but I don't think there is one.

#10 Updated by Constantin Asofiei about 1 year ago

Please see note #10284-8 and also make this exception handling common code.

#11 Updated by Teodor Gorghe about 1 year ago

Constantin Asofiei wrote:

Please see note #10284-8 and also make this exception handling common code.

Ok. I will do after I merge 10294a.

#12 Updated by Teodor Gorghe about 1 year ago

  • Status changed from WIP to Review

Committed revision 16040 on task branch 10284a:
- Moved error handling logic into ErrorManager.
- Added more checks on indexOf.

#13 Updated by Constantin Asofiei about 1 year ago

Please move the method to JsonImport, not ErrorManager.

#14 Updated by Teodor Gorghe about 1 year ago

Committed revision 16041 on task branch 10284a:
- Moved error handling logic into JsonImport.

#15 Updated by Constantin Asofiei 12 months ago

  • Status changed from Review to Internal Test

Looks good, thanks.

#16 Updated by Teodor Gorghe 12 months ago

  • Related to Bug #10381: READ-JSON dataset handle method doesn't throw error when parsing a invalid JSON added

#17 Updated by Alexandru Lungu 12 months ago

  • Status changed from Internal Test to Merge Pending

#18 Updated by Alexandru Lungu 12 months ago

  • Status changed from Merge Pending to Test
  • % Done changed from 50 to 100

Branch 10284a was merged to trunk revision 16102 and archived.

Also available in: Atom PDF