Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Length of namespace is mis-calculated when creating new private namespace #5073

Closed
3 tasks done
easyfold opened this issue Jan 8, 2024 · 2 comments · Fixed by #5078
Closed
3 tasks done

Length of namespace is mis-calculated when creating new private namespace #5073

easyfold opened this issue Jan 8, 2024 · 2 comments · Fixed by #5078
Labels
bug Categorizes issue or PR as related to a bug.

Comments

@easyfold
Copy link

easyfold commented Jan 8, 2024

  • I have checked the discussions
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Describe the bug
In v2.2.0, when creating new private namespace, namespace length is calculated as prefix + namespace. This bug should have be fixed in #2784, but it's reverted in 109c98d

Copy link

dosubot bot commented Jan 8, 2024

🤖

Hello @easyfold! 👋

I'm Dosu, an AI here to assist you with Apollo bugs and queries while we wait for a human maintainer. I can also guide you in contributing to the apollo repository. Remember, no issue is too big or too small for us to handle together! 😉

Let's get this bug squashed! 🐛

The issue you're experiencing with the namespace length being calculated as prefix + namespace when creating a new private namespace in Apollo v2.2.0 is due to the shouldAppendNamespacePrefix() function returning $scope.appendNamespacePrefix, which is set to true by default. This is evident in the following code snippet from the NamespaceController.js file:

$scope.appendNamespacePrefix = true;

function shouldAppendNamespacePrefix() {
    return  $scope.appendNamespacePrefix;
}

When creating a new namespace, the concatNamespace() function is called, which checks the shouldAppendNamespacePrefix() function and if it returns true, it appends the prefix to the namespace:

$scope.concatNamespace = function () {
    if (!$scope.appBaseInfo) {
        return '';
    }
    var appNamespaceName = $scope.appNamespace.name ? $scope.appNamespace.name : '';
    if (shouldAppendNamespacePrefix()) {
        return $scope.appBaseInfo.namespacePrefix + appNamespaceName;
    }
    return appNamespaceName;
};

So, even though the issue was supposed to be fixed in #2784, it appears to have been reverted in 109c98d, and the namespace length is still being calculated as prefix + namespace.

The prefix + namespace calculation in the Apollo v2.2.0 codebase is used to construct the URL for the various API endpoints. For example, in the createNamespace method, the URL is constructed as follows:

url: AppUtil.prefixPath() + '/apps/:appId/namespaces',

Here, AppUtil.prefixPath() returns the base URL and '/apps/:appId/namespaces' is the specific endpoint for creating a new namespace. The :appId is a placeholder that will be replaced with the actual appId when the method is called. This approach allows for flexibility and maintainability in the code. If the base URL changes, it only needs to be updated in one place (AppUtil.prefixPath() function) and all the API calls will still work correctly. This is evident in the NamespaceService.js file.

I hope this clarifies the issue. If you have any further questions, feel free to ask.

Best regards,
Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@nobodyiam
Copy link
Member

nobodyiam commented Jan 9, 2024

Thanks for reporting this issue. This is a bug introduced in 109c98d.

@nobodyiam nobodyiam added the bug Categorizes issue or PR as related to a bug. label Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants