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

Child folder environment variable should override parent folder variables #318

Closed
overbit opened this issue Mar 6, 2025 · 6 comments
Closed

Comments

@overbit
Copy link

overbit commented Mar 6, 2025

Currently, if an env variable is available in both, parent and child folder, the parent would be used.
The more sensible behaviour is that more specific definitions will override less specific ones.

@flawiddsouza
Copy link
Owner

Hi, actually the child folder variable itself would be used in this case.

If parent has a = 10 and child folder has a = 20, using {{ a }} in any request, would resolve a to 20.

Let me know if you're seeing different behavior and please provide a reproduction.

@flawiddsouza
Copy link
Owner

flawiddsouza commented Mar 14, 2025

I'll closing this issue for now, as the current behavior is already as you expect. Please feel free to reopen this if you find an issue.

Detailed explanation of env precedence can be found here: #268.

@overbit
Copy link
Author

overbit commented Mar 14, 2025

@flawiddsouza I think probably is a usage issue. A user can add many environments per folder but there doesn't seem to be related to the selector on the header.

Take the following example of a restfox export. How can I select an environment that will be reflected in the child env too?

{
    "exportedFrom": "Restfox-1.0.0",
    "collection": [
        {
            "_id": "2eL1G0AaPH1JhUJMBQryl",
            "_type": "request_group",
            "name": "parent",
            "parentId": null,
            "workspaceId": "l_JNx7_PGIiXZvF7vnyzn",
            "collapsed": false,
            "currentEnvironment": "Default",
            "sortOrder": 1,
            "environments": [
                {
                    "name": "Default",
                    "environment": {},
                    "color": "#000000"
                }
            ],
            "environment": {},
            "plugins": []
        },
        {
            "_id": "rQHA_0hRDNWReq4b7EKWO",
            "_type": "request_group",
            "name": "child",
            "parentId": "2eL1G0AaPH1JhUJMBQryl",
            "workspaceId": "l_JNx7_PGIiXZvF7vnyzn",
            "collapsed": false,
            "currentEnvironment": "env 1",
            "sortOrder": 0,
            "environments": [
                {
                    "name": "env 1",
                    "environment": {
                        "tld": "co.uk"
                    },
                    "color": "#000000"
                },
                {
                    "name": "env 2",
                    "environment": {
                        "tld": "com"
                    },
                    "color": "#a15959"
                }
            ],
            "plugins": []
        },
        {
            "_type": "request",
            "method": "GET",
            "body": {
                "mimeType": "No Body"
            },
            "url": "{{baseUrl}}",
            "sortOrder": 0,
            "parameters": [],
            "pathParameters": [],
            "_id": "46baN_Fl6FyOVbpD724z9",
            "parentId": "rQHA_0hRDNWReq4b7EKWO",
            "name": "GET",
            "workspaceId": "l_JNx7_PGIiXZvF7vnyzn",
            "plugins": []
        }
    ],
    "environments": [
        {
            "name": "env 1",
            "color": "#000000",
            "environment": {
                "baseUrl": "https://google.{{tld}}",
                "tld": "com"
            }
        },
        {
            "name": "env 2",
            "color": "#000000",
            "environment": {
                "baseUrl": "https://google.{{tld}}",
                "tld": "com"
            }
        }
    ]
}

@flawiddsouza
Copy link
Owner

Oh yes. The environment selector at the top is for the whole workplace. If you're using the folder environments, click on your preferred environment in the sidebar of the folder environment editor. That will make it the active env for that folder. Currently there's no other way to switch folder environments. But there is a feature request open for that: #312.

You've named both the folder and workspace environments with the same name, which might be causing confusion. The top environment will only show workspace environments.

Overriding is based on the active environment and not the name of the environment.

@overbit
Copy link
Author

overbit commented Mar 17, 2025

The entire environment selection is a bit counter-intuitive and not really aligned to other competitor products. I'd suggest to align and allow global variable selection with folder override with only 1 selection @flawiddsouza

@flawiddsouza
Copy link
Owner

I'm not sure which client has environments implemented in the way you mentioned above. I checked Postman and Insomnia and wasn't able to find the pattern you suggested. Can you let me know which client you're referring to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants