Skip to content

feat: update allowPort check#8355

Merged
f2c-ci-robot[bot] merged 1 commit intodevfrom
pr@dev@mcp
Apr 9, 2025
Merged

feat: update allowPort check#8355
f2c-ci-robot[bot] merged 1 commit intodevfrom
pr@dev@mcp

Conversation

@zhengkunwang223
Copy link
Copy Markdown
Member

No description provided.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented Apr 9, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

}
}
open.value = true;
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no obvious issues with the provided code fragment, but there's a minor suggestion for improvement:

Optimizations/Suggestions

  • Avoid Unnecessary Try/Catch: The try/catch block around API calls is not strictly necessary here, especially given that we only care about handling potential errors when setting up the website URL (if available). We can simplify this by removing the catch block.

Here's the revised version of the relevant part:

const acceptParams = async (params: AI.McpServer) => {
    hasWebsite.value = false;
    mode.value = params.id ? 'edit' : 'create';
    
    try {
        const mcpDomainRes = await getMcpDomain();
        
        if (mcpDomainRes.data.connUrl != '') {
            hasWebsite.value = true;
        }
    } finally { // Ensure that the state is correctly updated regardless of success or failure
        if (hasWebsite.value) {
            let parts = mcpDomainRes.data.connUrl.split(/(https?:\/\/)/).filter(Boolean);
            mcpServer.value.protocol = parts[0];
            mcpServer.value.url = parts[1];
            mcpServer.value.baseUrl = mcpDomainRes.data.connUrl;
        }
    }

    ...
}      

If you want to explicitly handle errors without affecting the logic flow elsewhere, consider using logging instead or wrapping it in a separate error handler function that checks if the operation should be retried. However, for simpler setup workflows, the current approach should suffice.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 9, 2025

Copy link
Copy Markdown
Member

@wanghe-fit2cloud wanghe-fit2cloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@wanghe-fit2cloud
Copy link
Copy Markdown
Member

/approve

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented Apr 9, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wanghe-fit2cloud

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot Bot added the approved label Apr 9, 2025
@f2c-ci-robot f2c-ci-robot Bot merged commit 5ab8377 into dev Apr 9, 2025
6 checks passed
@f2c-ci-robot f2c-ci-robot Bot deleted the pr@dev@mcp branch April 9, 2025 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants