Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException Error when importing a new API with system quotas #474

Closed
gcornacchia opened this issue Mar 21, 2024 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@gcornacchia
Copy link
Contributor

gcornacchia commented Mar 21, 2024

APIM-CLI version

1.14.3

API-Management version

7.7.20211130

Bug description

When I try to import a new frontend api definition with system quotas (per operation) included in JSON file an error occurs.

Steps to reproduce

Consider the following zip file where you can find the frontend api definition in json format for apim-cli and relative swagger file.
PetStoreAPI.zip

  1. import your API PetStoreAPI.json for the first time (the API must not yet exist on API Manager)

If I run the following import command:

> apim.sh API import -c PetStoreAPI.sjon -s myEnv -retryDelay 3000

I got the following log

2024-03-21 15:31:20,456 [APIManagerCLI] INFO : API-Manager CLI: 1.14.3
2024-03-21 15:31:20,458 [APIManagerCLI] INFO : Module: API - I M P O R T (1.14.3)
2024-03-21 15:31:20,472 [CoreParameters] INFO : Retrying unexpected API-Manager REST-API responses with a delay of 3000 milliseconds.
2024-03-21 15:31:21,955 [APIManagerAdapter] INFO : Successfully connected to API-Manager (7.7.20211130) on: https://192.168.144.105:8076
2024-03-21 15:31:22,340 [APISpecificationFactory] INFO : Reading API-Definition (Swagger/WSDL) from file: D:\Git\manager\apis\swagger\petstore.json (absolute path)
2024-03-21 15:31:22,363 [APISpecificationFactory] INFO : Detected: Swagger 2.0 specification.
2024-03-21 15:31:22,364 [Swagger2xSpecification] INFO : Overriding host scheme and basePath with value : http://backend
2024-03-21 15:31:22,671 [APIImportConfigAdapter] INFO : Handling configured client-applications.
2024-03-21 15:31:22,672 [APIImportApp] INFO : Lookup actual API based on Path: /petstorewithquota
2024-03-21 15:31:23,913 [APIImportManager] INFO : No existing API found, creating new!
2024-03-21 15:31:24,354 [CreateNewAPI] INFO : Create published API: PetStoreWithQuotaAPI 1.0 based on Swagger 2.0 specification.
2024-03-21 15:31:25,838 [APIQuotaManager] INFO : Updating System default quota for API: PetStoreWithQuotaAPI
2024-03-21 15:31:26,069 [APIImportApp] ERROR: null
java.lang.NullPointerException
at com.axway.apim.apiimport.actions.APIQuotaManager.addOrMergeRestriction(APIQuotaManager.java:90)
at com.axway.apim.apiimport.actions.APIQuotaManager.updateRestrictions(APIQuotaManager.java:74)
at com.axway.apim.apiimport.actions.APIQuotaManager.execute(APIQuotaManager.java:46)
at com.axway.apim.apiimport.actions.CreateNewAPI.execute(CreateNewAPI.java:98)
at com.axway.apim.apiimport.APIImportManager.applyChanges(APIImportManager.java:47)
at com.axway.apim.APIImportApp.importAPI(APIImportApp.java:93)
at com.axway.apim.APIImportApp.importAPI(APIImportApp.java:52)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.axway.apim.cli.APIManagerCLI.run(APIManagerCLI.java:131)
at com.axway.apim.cli.APIManagerCLI.main(APIManagerCLI.java:74)

If I run the import for the second time the API is correctly imported (quotas included).

2024-03-21 15:44:52,239 [UpdateExistingAPI] INFO : Update existing published API: PetStoreWithQuotaAPI 1.0 (ID: a636807c-b6bb-4d73-b696-1fc504f8cda5)
2024-03-21 15:44:52,241 [APIQuotaManager] INFO : Updating System default quota for API: PetStoreWithQuotaAPI
2024-03-21 15:44:52,242 [APIQuotaManager] INFO : Removing existing Quotas for API: PetStoreWithQuotaAPI as quotaMode is set to replace.
2024-03-21 15:44:52,843 [APIQuotaManager] INFO : Application default quota for API: PetStoreWithQuotaAPI is UN-CHANGED. Nothing to do.
2024-03-21 15:44:52,843 [ManageClientOrganization] INFO : reCreation : false
2024-03-21 15:44:52,844 [ManageClientOrganization] INFO : All desired organizations: ['Community'] have already access. Nothing to do.
2024-03-21 15:44:52,844 [ManageClientApps] INFO : All desired applications: [] have already a subscription. Nothing to do.
2024-03-21 15:44:52,845 [UpdateExistingAPI] INFO : Successfully updated published API: PetStoreWithQuotaAPI 1.0 (ID: a636807c-b6bb-4d73-b696-1fc504f8cda5)

Relevant log output

No response

@gcornacchia gcornacchia added the bug Something isn't working label Mar 21, 2024
@rathnapandi rathnapandi self-assigned this Mar 21, 2024
rathnapandi pushed a commit that referenced this issue Mar 21, 2024
@rathnapandi
Copy link
Member

Hi @gcornacchia,

I have fixed the issue, but when I reimport the same configuration, it is not throwing an errer saying no changes detected. Hence I am keeping the issue #475

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants