Closed ym-corey closed 2 months ago
Hey Corey, I just tried and wasn't able to reproduce it using those lines above. Are you using version 3.0.7 by chance?
I'm sorry, I've misrepresented the issue. The error is not thrown when you set the values but rather after you've encoded the GppModel and attempt to later decode it:
This is my pom.xml dependency:
<dependency>
<groupId>com.iabgpp</groupId>
<artifactId>iabgpp-encoder</artifactId>
<version>3.0.7</version>
</dependency>
Full example code:
var gppModel = new GppModel();
gppModel.setFieldValue(TcfEuV2.NAME, TcfEuV2Field.PURPOSE_CONSENTS, Arrays.asList(true, true, true, true, true, true, true, true, true));
gppModel.setFieldValue(TcfEuV2.NAME, TcfEuV2Field.VENDOR_CONSENTS, Arrays.asList(1, 173, 722));
var encoded = gppModel.encode();
try {
var gppModelDecoded = new GppModel(encoded); // thrown while decoding the encoded value
} catch (Throwable e) {
e.printStackTrace();
}
Exception thrown:
java.lang.Error: Unable to decode VendorConsents
at com.iab.gpp.encoder.section.AbstractEncodableSegmentedBitStringSection.decodeSegmentsFromBitStrings(AbstractEncodableSegmentedBitStringSection.java:78)
at com.iab.gpp.encoder.section.TcfEuV2.decode(TcfEuV2.java:209)
at com.iab.gpp.encoder.section.TcfEuV2.<init>(TcfEuV2.java:40)
at com.iab.gpp.encoder.GppModel.decode(GppModel.java:225)
at com.iab.gpp.encoder.GppModel.<init>(GppModel.java:32)
at com.yieldmo.adserver.AdServerRegressionTest.getGppTcfConsentFor(AdServerRegressionTest.java:330)
at com.yieldmo.adserver.AdServerRegressionTest.<clinit>(AdServerRegressionTest.java:137)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:375)
at com.intellij.junit5.JUnit5TestRunnerUtil.loadMethodByReflection(JUnit5TestRunnerUtil.java:124)
at com.intellij.junit5.JUnit5TestRunnerUtil.buildRequest(JUnit5TestRunnerUtil.java:100)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:43)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.StringIndexOutOfBoundsException: begin 213, end 17, length 336
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4601)
at java.base/java.lang.String.substring(String.java:2704)
at com.iab.gpp.encoder.datatype.EncodableOptimizedFixedRange.substring(EncodableOptimizedFixedRange.java:65)
at com.iab.gpp.encoder.section.AbstractEncodableSegmentedBitStringSection.decodeSegmentsFromBitStrings(AbstractEncodableSegmentedBitStringSection.java:74)
I have tried a few "random" values and series of values. I have not identified what/where the fault is.
Yeah, that's definitely an issue. I'll take a look.
On Thu, Jan 12, 2023 at 8:31 PM Corey @.***> wrote:
I'm sorry, I've misrepresented the issue. The error is not thrown when you set the values but rather after you've encoded the GppModel and attempt to later decode it:
This is my pom.xml dependency:
com.iabgpp iabgpp-encoder 3.0.7 Full example code:
var gppModel = new GppModel(); gppModel.setFieldValue(TcfEuV2.NAME, TcfEuV2Field.PURPOSE_CONSENTS, Arrays.asList(true, true, true, true, true, true, true, true, true));gppModel.setFieldValue(TcfEuV2.NAME, TcfEuV2Field.VENDOR_CONSENTS, Arrays.asList(1, 173, 722)); var encoded = gppModel.encode(); try { var gppModelDecoded = new GppModel(encoded); // thrown while decoding the encoded value } catch (Throwable e) { e.printStackTrace(); }
Exception thrown:
java.lang.Error: Unable to decode VendorConsents at com.iab.gpp.encoder.section.AbstractEncodableSegmentedBitStringSection.decodeSegmentsFromBitStrings(AbstractEncodableSegmentedBitStringSection.java:78) at com.iab.gpp.encoder.section.TcfEuV2.decode(TcfEuV2.java:209) at com.iab.gpp.encoder.section.TcfEuV2.
(TcfEuV2.java:40) at com.iab.gpp.encoder.GppModel.decode(GppModel.java:225) at com.iab.gpp.encoder.GppModel. (GppModel.java:32) at com.yieldmo.adserver.AdServerRegressionTest.getGppTcfConsentFor(AdServerRegressionTest.java:330) at com.yieldmo.adserver.AdServerRegressionTest. (AdServerRegressionTest.java:137) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:375) at com.intellij.junit5.JUnit5TestRunnerUtil.loadMethodByReflection(JUnit5TestRunnerUtil.java:124) at com.intellij.junit5.JUnit5TestRunnerUtil.buildRequest(JUnit5TestRunnerUtil.java:100) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:43) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)Caused by: java.lang.StringIndexOutOfBoundsException: begin 213, end 17, length 336 at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4601) at java.base/java.lang.String.substring(String.java:2704) at com.iab.gpp.encoder.datatype.EncodableOptimizedFixedRange.substring(EncodableOptimizedFixedRange.java:65) at com.iab.gpp.encoder.section.AbstractEncodableSegmentedBitStringSection.decodeSegmentsFromBitStrings(AbstractEncodableSegmentedBitStringSection.java:74) I have tried a few "random" values and series of values. I have not identified what/where the fault is.
— Reply to this email directly, view it on GitHub https://github.com/IABTechLab/iabgpp-java/issues/21#issuecomment-1381270080, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA373VJCJLEWHWCQV6WXSLWSDD73ANCNFSM6AAAAAATZOVDOY . You are receiving this because you commented.Message ID: @.***>
Fixed in 3.0.8
Thanks, I've confirmed it works now from my end.
Hi IAB team,
When attempting to fill Vendor Consents and Express/Implied Consents (depending on the type of TCF we're dealing with) I am unable to apply consent for Yieldmo (173) or DV360 (722) etc., as the library throws a
StringIndexOutOfBoundsException
.Can you clarify how the values of TcfEuV2Field.VENDOR_CONSENTS (and other fields referenced below) are intended to be provided to the Encoder API as well as how they are intended to be read from the Decoded GppModel?
Thanks, Corey