This little guide explains errors which may happen in the encoding/decoding process with Go APER library.
bits Value is over capacitycan occur as an output ofputBitsValue()function.- It happens when you're trying to encode value in lesser amount of bits than it requires, e.g., encoding 10 (1010 in binary) in 3 bits is impossible.
constraint Value is large than 65536can occur as an output ofappendConstraintValue()function.- It happens if in the value range in encoding, of typically
INTEGER, is larger than65536. If this boundary is exceeded, then different set of rules for large numbers encoding have to be applied.
- It happens if in the value range in encoding, of typically
bitString Length is over upperbound:can occur as an output ofappendBitString()function.- It happens case of the constrained
BitString, which doesn't have asizeExtflag (= can't be extended). If the amount of bits in theBitStringvalue is more than the upperbound, then this error is raised.
- It happens case of the constrained
bitString Length is not match fix-sized:can occur as an output ofappendBitString()function.- It can happen with the fixed-size
BitString(upperbound and lowerbound are the same), if theBitStringvalue doesn't match pre-definedBitStringlength.
- It can happen with the fixed-size
OctetString Length is over upperboundcan occur as an output ofappendOctetString()function.- It happens when the constrained
OctetString(represented as[]byte{}) length is larger than the defined upperbound and there is nosizeExtflag (=OctetStringcan't be extended).
- It happens when the constrained
OctetString Length is not match fix-sized:can occur as an output ofappendOctetString()function.- Same as for BitString.
- It can happen with the fixed-size OctetString (upperbound and lowerbound are the same), if the OctetString value doesn't match pre-defined OctetString length.
Error encoding REAL - value (%v) is lower than lowerbound (%v)orError encoding REAL - value (%v) is higher than upperbound (%v)can occur as an output ofappendReal()function.- It literally tells that the constrained
REALvalue exceeded the lowerbound or upperbound.
- It literally tells that the constrained
Error encoding REAL - numerical argument is out of domainis raised inappendReal()function, when the0value is encoded. it is currently not supported in Go APER library.Error encoding REAL - checksum verification failed. Encoded %v bytes, expected %v bytes to encodeis raised inappendReal()when the actual number of encoded bytes doesn't match expected number bytes to be encoded.INTEGER value is smaller than lowerbound:orINTEGER value is larger than upperbound:is raised inappendInteger()when the encoded value of a constrainedINTEGERexceeds lowerbound or upperbound.SEQUENCE OF Size is larger than upperbound:orSEQUENCE OF Size is lower than lowerbound:is raised inparseSequenceOf()function when the number of items in the list is larger/lower than the maximum/minimum size of the list (amount of items).encoding Length %d != fix-size %dcan be raised inparseSequenceOf()function in case of the list which has a fixed size and the number of items inside the list doesn't match this condition.the upper bound of CHOICE is missingis raised in theappendChoiceIndex()function if the CHOICE map entry is corrupted.- It happens when CHOICE map doesn't have an entry for certain CHOICE option, e.g., if entry for CGI in E2SM-RC would be an empty one.
unsupport value of CHOICE type is in Extensed:is raised in theappendChoiceIndex()function if the CHOICE can be extended and the item, which is being encoded, is not defined in the CHOICE extension, e.g., if with this definition of ENB-ID in E2SM-RC we tried to encode the 5th item, which doesn't exist.- Example from the above can happen in communication of different SM versions.
- In practice, this error often happens either if one of the CHOICE map entries is missed or if we forgot to put
fromChoiceExtflag on the item from CHOICE extension.
unsupport value of CHOICE type:is raised in theappendChoiceIndex()function if the currently encoded item (not from the CHOICE extension) is not defined in the CHOICE map entry.per: Value %v has exceeded its possible upperbound and shouldn't be encoded as a Normally small non-negative whole numberis raised inappendNormallySmallNonNegativeWholeNumber()function if the range of the encoded value exceeds32767. If this boundary is exceeded, then different set of rules have to be applied.CHOICE index in canonical ordering for %v was not passed, please check encoding schemais raised in theappendCanonicalChoiceIndex()function.- It happens when the
uniqueflag is not passed and the encoder doesn't know which CHOICE option it encodes.
- It happens when the
Expected to have key (%v) in CanonicalChoiceMapis raised in theappendCanonicalChoiceIndex()function when it can't find a CHOICE map entry for parsed CHOICE option.- Solution here is to revisit your CHOICE map and make sure that all CHOICEs from the ASN.1 definition are included.
UNIQUE ID (%v) doesn't correspond to it's choice option (%v), got %vis raised in theappendCanonicalChoiceIndex()function when passed CHOICE option doesn't match the obtained from CHOICE map entry.aper: cannot marshal nil valueis raised in themakeField()function if the obtained Golang structure is nil (applies for only mandatory items in the message).- Solution is to include the missing item in the message.
Expected %d BitString byte(s) to contain %d bits. Got %dis raised in themakeField()function if the BitString value doesn't matchBitStringlength.Expected last %d bits of byte array to be unused, and to contain only trailing zeroes. %sis raised in themakeField()function, if the last few bits of aBitStringare required to be trailing zeroes, but they are not.- For example,
BitStringwith length 18, has to store its value in 3 bytes, e.g.,[]byte{0xFF, 0xFF, 0xFF}. The last byte should have last 6 bits zeroed (3*8 - 18 = 6). In that case, validBitStringshould be[]byte{0xFF, 0xFF, 0xC0}.
- For example,
nil element in SEQUENCE typeis raised in themakeField()function if it gets a nil item (applied for mandatory items in the message).- Solution is to include the missing item in the message.
Expected a (canonical) choice map withis raised in themakeField()function if in the canonical CHOICE map an entry for the item is not present in the canonical CHOICE map.choice Index is nil at Fieldis raised in themakeField()function if the APER tag is not included in the Golang driven Protobuf structure.Expected a choice map with %sis raised in themakeField()function if the CHOICE map entry for the item is not present in the CHOICE map.unsupported: Type:is raised in themakeField()function if the encoding of this particular type of the structure is not supported in the Go APER library.
Get bits overflow, requireBits: %d, leftBits: %dis raised in theGetBitString()function when the requested amount of bits to decode is larger than what is left in the unparsed bits.- Possible root cause is some missing APER tags or some additional APER tags, which are not required per ASN.1 definition.
Align Bit is not zero in (see last octet)is raised in theparseAlignBits()function if the bits, which are expected to be an alignment bits (= zero bits) are not zeroes.- That means that some information is present in these bits. That may happen if some APER tags are missing.
Value range is negativeis raised in theparseConstraintValue()function.- It usually happens if the upperbound is lower than the lowerbound.
Constraint Value is large than 65536is raised in theparseConstraintValue()function when the decoding value range is greater than65536.- In case it is greater, a different set of decoding rules is applied.
Parsed Length Out of Constraintis raised in theparseLength()function if the length of aBitStringor anOctetStringwasn't encoded with regard to the chapter 10.9.3.6 or 10.9.3.7 of the ITU-T X.691 recommendation.PER data out of rangeis raised if the Go APER library thinks that it parsed more bytes than it actually did.- This normally doesn't happen. If it does, enable debug mode in the Go APER library and try to see where the decoding gets stuck.
Error while parsing encoding base of REAL, obtainedis raised inparseReal()function if the encoding base of theREALnumber is not 2.- This issue may occur only if in the encoder is used other encoding base for
REALnumbers than 2. In this case, encoder is not aligned with ITU-T X.691 recommendation.
- This issue may occur only if in the encoder is used other encoding base for
Error parsing scaling factor - decoded bits expected to be 0, obtained %vis raised inparseReal()function.- It means that the encoder, which produced APER bytes, is not compliant with ITU-T X.691 recommendation.
Error parsing exponent - decoded bits expected to be 0, obtained %vis raised inparseReal()function.- Again, it means that the encoder, which produced APER bytes, is not compliant with ITU-T X.691 recommendation.
Parse Constraint Value failed:is raised inparseSequenceOf()function, and it means that the decoder failed to parse the length of the list.- That may happen due to invalid constraints of list, if
sizeLBorsizeUBtags are missing.
- That may happen due to invalid constraints of list, if
the upper bound of CHOICE is missingis raised ingetChoiceIndex()function if no entries from CHOICE map were parsed.- It is practically the same error as was described in the Errors which can be obtained during encoding section.
sequence truncatederror is raised inparseField()function if all APER bytes passed at input were processed, but the decoder still expects bytes for some other items from the message.- In practice, this issue may occur if you pass only part of the bytes, but not all of them to the decoder.
Expected a choice map with %sis raised in theparseField()function if the CHOICE map entry for the item is not present in the CHOICE map.Didn't find UNIQUE flag. Please revisit ASN1 definitionis raised inparseField()function if no structure were defined to be a constrained for CHOICE encoding in canonical order.- This is caused by missing
uniqueflag in the Go driven Protobuf structure. Solution here would be to revisit ASN.1 definition and adjust your Protobuf to have auniquetag.
- This is caused by missing
Expected choice map %s to have index %dis raised inparseField()function when the CHOICE map doesn't have an entry for parsed item.- Solution here is to revisit your CHOICE map and make sure that all CHOICEs from the ASN.1 definition are included.
Expected an index %d in a choice map with %sis raised in theparseFieldstructure.- The root cause and the solution are similar to the ones described in the Errors which can be obtained during encoding section.
unsupported value of CHOICE type is in Extensed was found. It's not possible to decode it without knowing itis raised inparseField()function.- This error is raised when there is only single entry in the CHOICE map and the extension bit is found.
- Extension bit tells the decoder that the item from the extension should be decoded, but CHOICE map doesn't have any information about items which belong to the extension. In this case decoder doesn't know what structure to decode and thus panic
- This may happen in the E2* communication of different versions.
- This error is raised when there is only single entry in the CHOICE map and the extension bit is found.
unsupported: %s Kind:is raised inparseField()if the item type decoding is not supported in the Go APER library.