-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Bug] when importing Postman collection, requests with same name in the same folder are ignored #799
Comments
@helloanoop This looks to be a side effect of the Collection Item files being stored using the name of the request as the file name. The piece that handles the import-collection ipc call is just overwriting the "duplicate" item because the filePath will be computed as being the same. I think a solution would be to use something like the item.uid as the file name (the request names will still come over as they are stored in the I would say in general that collection items with the same name SHOULD be allowed even when creating using the UI "New Request" process. |
We had the same problem with the insomnia collection import, this was fixed in #264. We probably need the same fix here. |
While that would work. I think resolving the problem of collection items in the same folder not being allowed to have the same name would be more ideal and solve this issue across the board. |
If it is going to be a "rule" of bru that requests in a collection cannot have the same name (because |
In the meantime I'm treating my Postman collections with this script before importing - prefixing all request names with HTTP method. import argparse
import json
parser = argparse.ArgumentParser()
parser.add_argument('--file', dest='file', required=True, help="Postman collection JSON file to alter")
parser.add_argument('--in-place', action='store_true', dest='in_place', default=False, help="Whether to edit file in place")
args = parser.parse_args()
with open(args.file, "r") as file:
collection = json.load(file)
# check if this is a collection file just for sanity sake
if not str(collection.get("info", {}).get("schema", "")).endswith("collection.json"):
raise Exception("Could not verify that this is a Postman collection file")
def adjust_name(item):
items = item.get("item")
if items is not None:
for nested_item in items:
adjust_name(nested_item)
return
request = item.get("request")
if request is None:
raise Exception("Not a request: " + str(item))
item["name"] = str(request["method"]).lower() + "-" + (item['name'] if item["name"][0].isalnum() else item["name"][1:])
adjust_name(collection)
if not args.in_place:
print(json.dumps(collection, indent=4))
else:
with open(args.file, "w") as file:
json.dump(collection, file, indent=4) $ python3 prefix_request_names.py --file DCC.postman_collection.json --in-place |
Amen! Name and Method should define uniqueness for a request. |
Shouldn't this be a high priority? Basically Postman imports are broken due to this issue. |
Many thanks for sharing. Saved me a some work and I was able to import a large postman collection :-) |
Can't we just save what we are importing as we go and then append -2 -3 if we find more? FWIW, when I import my Postman collection of 56 actions, I get 46 actions in Bruno! |
Doesn't help for my case.
Can't we just do a quick fix only to postman import? Changing the structure to not allow duplicate names, um, why not just have "seq"-name after all? Are duplicate seq allowed? "seq"-name would also be NICE for collating in a file explorer... ijs, you have this file-system-simplicity concept, which I like, but, seq is more meaningful than arbitrary alpha or date sort. Again, just fix the POSTMAN IMPORT to do seq-name or seq_name or name-1 name-2 or name name-2 FIRST, has to be more easy and isolated... Using UID for filename is a BAD IDEA.
No. I have a Postman collection with 67 entries. It is structured like this: "auth" post While in concept "auth" could be reused with seq 1 and seq 8 both being "auth", "thing 1" has differences in the test script, etc... This is a postman import problem for LOTS of existing postman collections. Importing the above gives: seq 2 thing1 Notice it totally breaks because it never authorized. The existence of auth again is because some are slow and the token times out. When I import my 56 entry collection, it comes in as 46 requests! 21 out of 67 are just "silently dropped". It isn't OK to say "name and method should define uniqueness" when postman doesn't :) My suggestion is still: For now, make POSTMAN imports do names as "seq###-name" and long term make ALL filenames seq###-name... |
python to fix the postman json file prepending sequence numbers:
|
Encountered when importing a folder with multiple requests of the same name. Postman allows same naming of requests.
When there are multiple requests with the same name, only one of the requests is importing, while the other are ignored. There is no notice about this.
The text was updated successfully, but these errors were encountered: