The getPortMessageType function in PR #2037 throws an error if a port is not found. Consider logging the error or providing a default value to handle unexpected ports gracefully. See the comment here.
getPortMessageType