Hi Folks,A database exception is occurring while saving the record, please see details below
"String or binary data would be truncated in table 'OSPRD.dbo.TableName', column 'CARDNUMBER'. Truncated value: '52266122'.The statement has been terminated. "
Please note: Datatype of attribute CARDNUMBER is Text of length 8.Even though the attribute length is 8 and valid data is being passed that is passing a value of length 8 and no extra spaces; however a database thrown exception.
I would appreciate your assistance!
Thanks
Hi @Meer Imtiyaz Ali,
One more observation from your error message.
Just going by the English Language. The message says Truncated Value: '52266122'. Emphasis on Truncated Value.
Is it possible the user has provided more than 8 characters and error message displays only the truncated value.
Can you add log messages for card number before saving to DB, so you can verify if actually correct cardnumber length was sent when the error occurred.
Cheers,
Saugat
Can you provide us with some context? What are the data types of the input as well as the expectation? Do you use the standard CreateOrUpdate-action of OutSystems?
Datatype is Text with length 8.
Yes, using standard CreateOrUpdate-action of OutSystems.Here scenario is, application captures an 8-digit input from the user and save it to DB.
Hi @Meer Imtiyaz Ali ,
Does this issue occur across all environments? Is the entity external or internal? Also, was the attribute length recently updated?
HI Mihai Melencu ,The exception occurs only in the production environment and is not reproducible in lower environments.
If the issue only occurs in PROD and the entity is internal, can you check if the version in prod has the right max length. Also you could do a republish and see if the issue persists.
If the issue occurs in the production environment (Prod), then there is definitely a difference between the source code in the development environment (Dev) and the production environment. You need to double-check.
For O11 you can open Prod environment
For ODC you can check revison on Prod.
Hi @Meer Imtiyaz AliYour error seems a bit tricky.
Even though CARDNUMBER is Text(8) in OutSystems and you are passing exactly 8 characters, SQL Server is rejecting it because the physical database column length is smaller than 8.
OutSystems does not dynamically enforce the database schema at runtime. What matters is the actual SQL column definition, not what Service Studio shows. So this error means one of the following is true:
Please validate each scenario and confirm everything is as expected.
Hope this helps,
hi @Meer Imtiyaz Ali if you are fetching data from an external source, for example SQL, then this error is coming from there — you have to check that first."
Thank you all for your responses!
However, the database attribute length is the same in both lower and Production environments.
This issue is intermittent and occurs only for certain records. The issue does not reproduce even when the same data is used.
Is it possible that something is getting injected during the submission process?
Validation is enforced at the UI end and input field does not accept more than 8 characters.@Saugat Biswas : You're right, data seems to be getting truncated, which suggests that some extra characters may be appended. That seems valid.
I have set up logs in the lower environment, but I need to wait for the production deployment, after which we will continue and share an update.
Many thanks to all of you for your help.
Hello everyone,
I enabled logging in Production and, during testing, discovered that some malicious data was being truncated, which caused this issue. After sanitizing the CardNumber field, the issue is resolved. A big thank you to everyone for your support and assistance in helping resolve this issue.