Skip to content

Commit

Permalink
Merge branch 'release/7.43.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
codenirvana committed Dec 11, 2024
2 parents b4f8101 + 01741da commit 8c53a35
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
7.43.1:
date: 2024-12-11
fixed bugs:
- >-
Fixed a bug where item's parent reference was missing from request and
response callback
7.43.0:
date: 2024-10-30
new features:
Expand Down
1 change: 1 addition & 0 deletions lib/runner/create-item-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = function (payload, defaults) {
// we clone item from the payload, so that we can make any changes we need there, without mutating the
// collection
context.item = new sdk.Item(payload.item.toJSON());
context.item.setParent(payload.item.parent());

// get a reference to the Auth instance from the item, so changes are synced back
context.auth = context.originalItem.getAuth();
Expand Down
2 changes: 2 additions & 0 deletions lib/runner/request-helpers-presend.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ module.exports = [
item = new sdk.Item({ request }),
originalItem = context.originalItem;

item.setParent(originalItem.parent());

// auth handler gave a no go, and an intermediate request.
// make the intermediate request the response is passed to `init` hook
// we are overriding the originalItem because in pre we have a entire new request
Expand Down
4 changes: 4 additions & 0 deletions lib/runner/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ module.exports = {

hasVaultSecrets = vaultValues ? vaultValues.count() > 0 : false,

itemParent = context.item.parent(),
urlObj = context.item.request.url,
// @note URL string is used to resolve nested variables as URL parser doesn't support them well.
urlString = urlObj.toString(),
Expand Down Expand Up @@ -310,6 +311,9 @@ module.exports = {
item = context.item = new sdk.Item(context.item.toObjectResolved(null,
variableDefinitions, { ignoreOwnVariables: true }));

// restore the parent reference
item.setParent(itemParent);

// re-parse and update the URL from the resolved string
urlString && (item.request.url = new sdk.Url(urlString));

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postman-runtime",
"version": "7.43.0",
"version": "7.43.1",
"description": "Underlying library of executing Postman Collections",
"author": "Postman Inc.",
"license": "Apache-2.0",
Expand Down
8 changes: 8 additions & 0 deletions test/integration/sanity/response-callback.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,13 @@ describe('response callback', function () {
// cursor
expect(testrun).to.have.nested.property('response.firstCall.args[1]').that.has.property('ref');
});

it('should have item\'s parent reference intact', function () {
const parent = testrun.beforeItem.firstCall.args[2].parent();

expect(testrun.request.firstCall.args[4].parent()).to.equal(parent);
expect(testrun.request.secondCall.args[4].parent()).to.equal(parent);
expect(testrun.response.firstCall.args[4].parent()).to.equal(parent);
});
});
});

0 comments on commit 8c53a35

Please sign in to comment.