Missing Checks for 'Publish' Button in the Publisher Portal
Description
Mandatory properties for APIs can be added in previous APIM versions like APIM 4.1.0. The expected behaviour is that when mandatory properties are not provided, a user cannot publish an API. API publishing can be done either from the API Overview page and the API Lifecycle page of the Publisher portal. Simply the ‘Publish’ button is not available if the mandatory properties are not provided.
However in 4.5.0, APIs can be published ('Publish' button is enabled) from the API Overview page even if the mandatory properties are not provided. However in Lifecycle page the ‘Publish’ button is unavailable without mandatory properties and hence Lifecycle page is working as expected.
The root cause of the error is a missing check for mandatory properties in Publisher portal UI code base which is present in earlier versions like 4.1.0.
Steps to Reproduce
- Add mandatory properties to deployment.toml
[[apim.publisher.custom_properties]] required=true name="testProp" description="Property for testing"
- Log in to the publisher portal
- Create an API
- Go to overview.
- Deploy the API and then click on the Publish button.
- The API will be get deployed and published without validating the mandatory properties.
Version
4.5.0
Environment Details (with versions)
No response
Fixed in WSO2 API Manager 4.6.0
This issue has been fixed in WSO2 API Manager 4.6.0. The Overview page now properly validates mandatory custom properties before enabling the Publish button, matching the behavior of the Lifecycle page.
Issue Summary
In APIM 4.5.0, when mandatory custom properties were configured in deployment.toml, the validation behaved inconsistently:
- ✅ Lifecycle Page: Correctly disabled "Publish" button when mandatory properties missing
- ❌ Overview Page: Allowed publishing even when mandatory properties not provided
Root Cause: Missing validation check for mandatory properties in the Overview page UI component.
Fix Details
Author: Nethmi Ranasinghe
File: portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/NewOverview/CustomizedStepper.jsx
What Changed:
- Added State for Validation (line 155):
const [isMandatoryPropertiesAvailable, setIsMandatoryPropertiesAvailable] = useState(false);
- Added Validation Function (lines 302-312):
const requiredPropertyNames = customProperties
.filter(property => property.Required)
.map(property => property.Name);
if (requiredPropertyNames.length > 0) {
setIsMandatoryPropertiesAvailable(requiredPropertyNames.every(propertyName => {
const property = api.additionalProperties.find(prop => prop.name === propertyName);
return property && property.value !== '';
}));
}
- Updated Publish Button Condition (line 592):
disabled={isPublishButtonDisabled || isDeployButtonDisabled || !isMandatoryPropertiesAvailable}
- Added Validation Tooltip (lines 600-609):
{!isMandatoryPropertiesAvailable && (
<div className={classes.alertWrapper}>
<Alert severity='error'>
<FormattedMessage
id='Apis.Details.NewOverview.Overview.mandatory.properties.not.available'
defaultMessage='Mandatory API Properties should be provided to publish an API'
/>
</Alert>
</div>
)}
How It Works
The fix ensures that:
- On component load,
validateMandatoryCustomProperties()checks if all required custom properties are filled - The function verifies each mandatory property has a non-empty value in
api.additionalProperties - The Publish button is disabled (
|| !isMandatoryPropertiesAvailable) when any mandatory property is missing - An error alert displays: "Mandatory API Properties should be provided to publish an API"
- This matches the existing behavior on the Lifecycle page
Verification Steps (Manual)
To verify this fix:
- Configure mandatory properties in
deployment.toml - Restart APIM 4.6.0 server
- Login to Publisher portal (https://localhost:9443/publisher)
- Create a new API
- Navigate to API Overview page
-
Without filling mandatory properties:
- ✅ Publish button should be disabled
- ✅ Error message should display: "Mandatory API Properties should be provided to publish an API"
-
After filling mandatory properties:
- ✅ Publish button should be enabled
- ✅ Error message should disappear
Conclusion
The Overview page now properly validates mandatory custom properties before allowing API publication, matching the behavior of the Lifecycle page. The fix ensures APIs cannot be published in an incomplete state when mandatory properties are configured.
Tested on: WSO2 API Manager 4.6.0 Status: ✅ Fixed Test Method: Code analysis - requires manual UI testing to verify button behavior