Fix global policy parameter retrieval when editing policies#1197
Fix global policy parameter retrieval when editing policies#1197
Conversation
|
|
Co-authored-by: HeshanSudarshana <25485783+HeshanSudarshana@users.noreply.github.com>
Co-authored-by: HeshanSudarshana <25485783+HeshanSudarshana@users.noreply.github.com>
|
@copilot To fix the issue don't consider backend SQLexceptions, the state is there when adding the global policy.. but when editing the state for those policy params seems to be empty. We need to fix this only |
Co-authored-by: HeshanSudarshana <25485783+HeshanSudarshana@users.noreply.github.com>
Fixed in commit 9bc8467. The issue was in the policy lookup logic in The component was only trying to match policies by I've added a fallback strategy that tries to match by policy identifiers ( Also added null-safety checks to prevent crashes if |
|
…development iteration



Problem
When editing Global Policies on WSO2 API Manager, users encounter an issue where policy parameter values are not displayed in the editor UI, leaving all fields blank. This prevents users from updating existing policies without re-entering all parameters.
Root Cause
The issue is in the frontend policy lookup logic in
PolicyConfigurationEditDrawer.tsx. When a user clicks to edit an existing policy, the component tries to find the policy inglobalLevelPoliciesby matching theuuidfield. However, this lookup can fail due to:globalLevelPoliciescontext may not be fully synchronized when the drawer opensWhen the lookup fails, the component creates a fallback object with empty
parameters: {}, resulting in blank form fields.Impact
Users who create policies with parameters (e.g., "Add Header" policy with
headerNameandheaderValue) cannot edit them later because:Solution
Enhanced the policy lookup logic in
PolicyConfigurationEditDrawer.tsxto be more robust:Changes Made
Modified File:
PolicyConfigurationEditDrawer.tsxImplementation:
globalLevelPolicies[currentFlow]is undefineduuid(matches theuniqueKeyon the policy card)policyId,policyName,policyVersion)Code Changes
Benefits
Testing
Related Issues
Fixes wso2/api-manager#4482
Original prompt
This section details on the original issue you should resolve
<issue_title>Global Policies cannot be Updated</issue_title>
<issue_description>### Description
After creating a global policy, it cannot be updated. The policy editor UI does not display the policy attribute values that were added during creation, leaving all fields blank. [DB Type: MSSQL]
[2025-10-17 18:12:59,397] WARN - ApiMgtDAO Failed to parse parameters from binary stream, using empty map
com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from varchar to BinaryStream is unsupported.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:250) ~[mssql-jdbc-13.2.1.jre11.jar:?]
at com.microsoft.sqlserver.jdbc.DataTypes.throwConversionError(DataTypes.java:1154) ~[mssql-jdbc-13.2.1.jre11.jar:?]
at com.microsoft.sqlserver.jdbc.ServerDTVImpl.getValue(dtv.java:3760) ~[mssql-jdbc-13.2.1.jre11.jar:?]
at com.microsoft.sqlserver.jdbc.DTV.getValue(dtv.java:257) ~[mssql-jdbc-13.2.1.jre11.jar:?]
at com.microsoft.sqlserver.jdbc.Column.getValue(Column.java:189) ~[mssql-jdbc-13.2.1.jre11.jar:?]
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2108) ~[mssql-jdbc-13.2.1.jre11.jar:?]
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2103) ~[mssql-jdbc-13.2.1.jre11.jar:?]
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getStream(SQLServerResultSet.java:2122) ~[mssql-jdbc-13.2.1.jre11.jar:?]
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getBinaryStream(SQLServerResultSet.java:2213) ~[mssql-jdbc-13.2.1.jre11.jar:?]
at org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.populateOperationPolicyWithRS_aroundBody1248(ApiMgtDAO.java:24832) ~[org.wso2.carbon.apimgt.impl_9.32.132.jar:?]
at org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.populateOperationPolicyWithRS(ApiMgtDAO.java:1) ~[org.wso2.carbon.apimgt.impl_9.32.132.jar:?]
at org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.getGatewayPoliciesOfPolicyMapping_aroundBody1306(ApiMgtDAO.java:25944) ~[org.wso2.carbon.apimgt.impl_9.32.132.jar:?]
at org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.getGatewayPoliciesOfPolicyMapping(ApiMgtDAO.java:1) ~[org.wso2.carbon.apimgt.impl_9.32.132.jar:?]
at org.wso2.carbon.apimgt.impl.APIProviderImpl.updateGatewayGlobalPolicies_aroundBody646(APIProviderImpl.java:8661) ~[org.wso2.carbon.apimgt.impl_9.32.132.jar:?]
at org.wso2.carbon.apimgt.impl.APIProviderImpl.updateGatewayGlobalPolicies(APIProviderImpl.java:1) ~[org.wso2.carbon.apimgt.impl_9.32.132.jar:?]
at org.wso2.carbon.apimgt.impl.UserAwareAPIProvider.updateGatewayGlobalPolicies(UserAwareAPIProvider.java:1) ~[org.wso2.carbon.apimgt.impl_9.32.132.jar:?]
at org.wso2.carbon.apimgt.rest.api.publisher.v1.impl.GatewayPoliciesApiServiceImpl.updateGatewayPoliciesToFlows(GatewayPoliciesApiServiceImpl.java:331) ~[?:?]
at org.wso2.carbon.apimgt.rest.api.publisher.v1.GatewayPoliciesApi.updateGatewayPoliciesToFlows(GatewayPoliciesApi.java:149) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) ~[?:?]
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) ~[?:?]
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201) ~[?:?]
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:104) ~[?:?]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) ~[?:?]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) ~[?:?]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) ~[?:?]
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) ~[?:?]
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) ~[?:?]
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) ~[?:?]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) ~[?:?]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) ~[?:?]
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:225) ~[?:?]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet....
Fixes wso2/api-manager#4482
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.