This is an automated email from the ASF dual-hosted git repository.
olabusayo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git
The following commit(s) were added to refs/heads/main by this push:
new fc05b68e0 Enhance InfosetNoDataException message to include circular
dependencies
fc05b68e0 is described below
commit fc05b68e08f240686588209dda7401097372a16a
Author: olabusayoT <[email protected]>
AuthorDate: Mon Feb 9 12:37:54 2026 -0500
Enhance InfosetNoDataException message to include circular dependencies
- Introduced test cases (`truncatedString_1`, `truncatedString_2`,
`truncatedString_3`, `truncatedString_4`) to check different scenarios that the
circular dependency occurs and doesn't occur
DAFFODIL-1598
---
.../daffodil/runtime1/infoset/InfosetImpl.scala | 7 +-
.../section00/general/testUnparserGeneral.tdml | 123 +++++++++++++++++++++
.../section00/general/TestUnparserGeneral.scala | 6 +
3 files changed, 135 insertions(+), 1 deletion(-)
diff --git
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/infoset/InfosetImpl.scala
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/infoset/InfosetImpl.scala
index 7d14db9c1..311057bc3 100644
---
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/infoset/InfosetImpl.scala
+++
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/infoset/InfosetImpl.scala
@@ -335,7 +335,12 @@ sealed abstract class InfosetNoDataExceptionBase(
case class InfosetNoDataException(
override val diElement: DIElement,
override val erd: ElementRuntimeData
-) extends InfosetNoDataExceptionBase(diElement, erd, "Element does not have a
value.")
+) extends InfosetNoDataExceptionBase(
+ diElement,
+ erd,
+ "Element does not have a value. " +
+ "This may indicate a circular dependency in the schema."
+ )
case class InfosetSelfReferencingException(
override val diElement: DIElement,
diff --git
a/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/testUnparserGeneral.tdml
b/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/testUnparserGeneral.tdml
index c8a226f4f..549cef279 100644
---
a/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/testUnparserGeneral.tdml
+++
b/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/testUnparserGeneral.tdml
@@ -994,4 +994,127 @@
<tdml:document>a</tdml:document>
</tdml:unparserTestCase>
+ <tdml:defineSchema name="truncatedString1">
+ <xs:include
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
+
+ <dfdl:format ref="ex:GeneralFormat" encoding="ascii"
+ lengthUnits="bytes"/>
+
+ <xs:element name="e1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="len" type="xs:int" dfdl:lengthKind="explicit"
dfdl:length="1"
+ dfdl:outputValueCalc="{ if (dfdl:valueLength(../ex:data , 'bytes')
gt 5) then 5 else dfdl:valueLength(../ex:data , 'bytes') }" />
+ <xs:element name="data" type="xs:string" dfdl:lengthKind='explicit'
+ dfdl:length='{../ex:len}'
dfdl:truncateSpecifiedLengthString='yes'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ </tdml:defineSchema>
+
+ <tdml:unparserTestCase name="truncatedString_1" root="e1"
model="truncatedString1">
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <ex:e1>
+ <ex:len>0</ex:len>
+ <ex:data>ABCDEFG</ex:data>
+ </ex:e1>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ <tdml:errors>
+ <tdml:error>not have a value</tdml:error>
+ <tdml:error>circular dependency</tdml:error>
+ </tdml:errors>
+ </tdml:unparserTestCase>
+
+ <tdml:defineSchema name="truncatedString2">
+ <xs:include
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
+
+ <dfdl:format ref="ex:GeneralFormat" encoding="ascii"
+ lengthUnits="bytes"/>
+
+ <xs:element name="e1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="len" type="xs:int" dfdl:lengthKind="explicit"
dfdl:length="1"
+ dfdl:outputValueCalc="{ if (fn:string-length(../ex:data) gt 5)
then 5 else fn:string-length(../ex:data) }" />
+ <xs:element name="data" type="xs:string" dfdl:lengthKind='explicit'
+ dfdl:length='{../ex:len}'
dfdl:truncateSpecifiedLengthString='yes'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </tdml:defineSchema>
+
+ <tdml:unparserTestCase name="truncatedString_2" root="e1"
model="truncatedString2">
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <ex:e1>
+ <ex:len>0</ex:len>
+ <ex:data>ABCDEFG</ex:data>
+ </ex:e1>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ <tdml:errors>
+ <tdml:error>not have a value</tdml:error>
+ <tdml:error>circular dependency</tdml:error>
+ </tdml:errors>
+ </tdml:unparserTestCase>
+
+ <tdml:defineSchema name="truncatedString3">
+ <xs:include
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
+
+ <dfdl:format ref="ex:GeneralFormat" encoding="ascii"
+ lengthUnits="bytes"/>
+
+ <xs:element name="e1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="data" type="xs:string" dfdl:lengthKind='explicit'
+ dfdl:length='{ if (fn:string-length(.) gt 5) then 5 else
fn:string-length(.) }' dfdl:truncateSpecifiedLengthString='yes'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </tdml:defineSchema>
+
+ <tdml:unparserTestCase name="truncatedString_3" root="e1"
model="truncatedString3">
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <ex:e1>
+ <ex:data>ABCDEFG</ex:data>
+ </ex:e1>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ <tdml:document>ABCDE</tdml:document>
+ </tdml:unparserTestCase>
+
+ <tdml:defineSchema name="truncatedString4">
+ <xs:include
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
+
+ <dfdl:format ref="ex:GeneralFormat" encoding="ascii"
+ lengthUnits="bytes"/>
+
+ <xs:element name="e1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="data" type="xs:string" dfdl:lengthKind='explicit'
+ dfdl:length="{ if (dfdl:valueLength(. , 'bytes') gt 5) then 5 else
dfdl:valueLength(. , 'bytes') }" dfdl:truncateSpecifiedLengthString='yes'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </tdml:defineSchema>
+
+ <tdml:unparserTestCase name="truncatedString_4" root="e1"
model="truncatedString4">
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <ex:e1>
+ <ex:data>ABCDEFG</ex:data>
+ </ex:e1>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ <tdml:errors>
+ <tdml:error>Value length unknown</tdml:error>
+ </tdml:errors>
+ </tdml:unparserTestCase>
+
</tdml:testSuite>
diff --git
a/daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestUnparserGeneral.scala
b/daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestUnparserGeneral.scala
index 93b272578..c380450f2 100644
---
a/daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestUnparserGeneral.scala
+++
b/daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestUnparserGeneral.scala
@@ -79,4 +79,10 @@ class TestUnparserGeneral extends TdmlTests {
@Test def emptyOutputNewLine1 = test
@Test def unparseIgnorableContent = test
+
+ // DFDL-1598
+ @Test def truncatedString_1 = test
+ @Test def truncatedString_2 = test
+ @Test def truncatedString_3 = test
+ @Test def truncatedString_4 = test
}