Skip to content

Increase the size of the INPUT column in the AM_APPLICATION_REGISTRATION table  #1761

@TomasWso2

Description

@TomasWso2

Problem

Hi Team

Experiencing the following error when migrating application between 2 identical environments:
ERROR {org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor} - Error occurred when updating the status of the Application creation process org.wso2.carbon.apimgt.api.APIManagementException: Error occurred while creating an Application Registration Entry for Application : TEST-APP
...
at org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.createApplicationRegistrationEntry_aroundBody4(ApiMgtDAO.java:273)
...
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'INPUTS' at row 1

Steps to reproduce:

  1. Create an application and generate production keys.
  2. Fill up the application with data like many additionalProperties or grant_types to increase the key´s character size.
  3. Export the application.
  4. Import it to the same environment after deleting the app or a new identical environment.

AM_APPLICATION_REGISTRATION table is used only to persist the details of the key generation request to be used back when application registration (key generation) is approved [1].
The App key generation occurs only after in the flow of code with the execution of method generateKeysForApplication at [2].. So when generating the keys for the first time the DB table is updated with the available information only. clientId, client secret, token_expiry_time, etc are not available.
Changing any configuration after, does not go thru the application registration flow, so the AM_APPLICATION_REGISTRATION table is not updated.
When we export an application with keys (with the apictl flag --with-keys=true), all these additional key related information/changes will be exported and saved in the exported archive.
So when we import the application to a new environment with keys, these information about keys are available when we are inserting the entry into AM_APPLICATION_REGISTRATION. As a result, the length in the value of INPUT field inserted here is increased.

According to the implementation, this is the expected behavior, but the value of this column is finite and it reaches max when all the fields are filled with data.
A solution is increase the length of the column manually.
ALTER TABLE AM_APPLICATION_REGISTRATION MODIFY INPUTS VARCHAR(7500);

It would be an improvement to increase the column size appropriately in the apim_db script to avoid this issue.

[1] https://github.com/wso2-support/carbon-apimgt/blob/support-6.7.206/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java#L221
[2] https://github.com/wso2-support/carbon-apimgt/blob/91d4b08438a2525b6ac0a506bcac30b6de60ed2a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/workflow/ApplicationRegistrationSimpleWorkflowExecutor.java#L77

Thanks,
Tomas

Solution

Increase the column size appropriately in the apim_db script to avoid this issue.

Affected Component

APIM

Version

4.0.0-148

Implementation

Increase the column size appropriately in the apim_db script to avoid this issue.

Related Issues

No response

Suggested Labels

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions