Library version: @iabgpp/cmpapi v3.1.5
toObj() in AbstractLazilyEncodableSection does not check the decoded flag
before returning data. As a result, it returns all default/zero values instead
of the actual decoded data from the encoded string.
Root cause:
All other methods (getFieldValue, hasField, setFieldValue) correctly trigger
lazy decoding with this guard:
this.decoded || (this.segments = this.decodeSection(this.encodedString), ...)
But toObj() is missing this check entirely — it just returns this.segments as-is,
which at construction time contains only default values.
To reproduce:
const model = new GppModel();
model.decode('DBABRg~BVqqqpY');
console.log(model.getSection('usva'));
Expected behaviour:
// SharingNotice: 1, SaleOptOut: 2, SensitiveDataProcessing: [2,2,...] etc.
Actual behaviour:
// SharingNotice: 0, SaleOptOut: 0, SensitiveDataProcessing: [0,0,...] etc.
Workaround (until fixed):
Call getFieldValue() on any field first to force the section to decode, then call getSection():
model.getFieldValue('usva', 'Version'); // triggers decode
model.getSection('usva'); // now returns correct data
Library version: @iabgpp/cmpapi v3.1.5
toObj()inAbstractLazilyEncodableSectiondoes not check thedecodedflagbefore returning data. As a result, it returns all default/zero values instead
of the actual decoded data from the encoded string.
Root cause:
All other methods (
getFieldValue,hasField,setFieldValue) correctly triggerlazy decoding with this guard:
this.decoded || (this.segments = this.decodeSection(this.encodedString), ...)
But
toObj()is missing this check entirely — it just returnsthis.segmentsas-is,which at construction time contains only default values.
To reproduce:
const model = new GppModel();
model.decode('DBABRg~BVqqqpY');
console.log(model.getSection('usva'));
Expected behaviour:
// SharingNotice: 1, SaleOptOut: 2, SensitiveDataProcessing: [2,2,...] etc.
Actual behaviour:
// SharingNotice: 0, SaleOptOut: 0, SensitiveDataProcessing: [0,0,...] etc.
Workaround (until fixed):
Call getFieldValue() on any field first to force the section to decode, then call getSection():
model.getFieldValue('usva', 'Version'); // triggers decode
model.getSection('usva'); // now returns correct data