api-manager icon indicating copy to clipboard operation
api-manager copied to clipboard

Missing Checks for 'Publish' Button in the Publisher Portal

Open Sanjaya-47 opened this issue 6 months ago • 1 comments

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

  1. Add mandatory properties to deployment.toml

[[apim.publisher.custom_properties]] required=true name="testProp" description="Property for testing"

  1. Log in to the publisher portal
  2. Create an API
  3. Go to overview.
  4. Deploy the API and then click on the Publish button.
  5. The API will be get deployed and published without validating the mandatory properties.

Version

4.5.0

Environment Details (with versions)

No response

Sanjaya-47 avatar Jul 15 '25 00:07 Sanjaya-47

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:

  1. Added State for Validation (line 155):
const [isMandatoryPropertiesAvailable, setIsMandatoryPropertiesAvailable] = useState(false);
  1. 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 !== '';
    }));
}
  1. Updated Publish Button Condition (line 592):
disabled={isPublishButtonDisabled || isDeployButtonDisabled || !isMandatoryPropertiesAvailable}
  1. 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:

  1. On component load, validateMandatoryCustomProperties() checks if all required custom properties are filled
  2. The function verifies each mandatory property has a non-empty value in api.additionalProperties
  3. The Publish button is disabled (|| !isMandatoryPropertiesAvailable) when any mandatory property is missing
  4. An error alert displays: "Mandatory API Properties should be provided to publish an API"
  5. This matches the existing behavior on the Lifecycle page

Verification Steps (Manual)

To verify this fix:

  1. Configure mandatory properties in deployment.toml
  2. Restart APIM 4.6.0 server
  3. Login to Publisher portal (https://localhost:9443/publisher)
  4. Create a new API
  5. Navigate to API Overview page
  6. Without filling mandatory properties:
    • ✅ Publish button should be disabled
    • ✅ Error message should display: "Mandatory API Properties should be provided to publish an API"
  7. 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

ranuka-laksika avatar Nov 24 '25 10:11 ranuka-laksika