Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Conversation

0xCLARITY
Copy link
Collaborator

High Level Overview of Change

Fix bug in header processing logic, and remove needlessly complex logic for the "Not Found" message we provide.

Context of Change

There was a bug in our header processing logic, which, if you requested payid+json to a non-existent PayID would respond with a 200 - OK, claiming that PayID existed with no addresses, rather than responding with a 404 - Not Found.

Relevant issue: #595

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

Test Plan

Added a test for the payid+json to a nonexistent PayID case, and it now passes (would fail on master).

message += `on ${environment} `
}
message += 'could not be found.'
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This felt complicated for no real reason, so I just cut it.

Copy link
Member

Choose a reason for hiding this comment

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

Definitely a little much for the error message.

@@ -57,6 +57,10 @@ export function getPreferredAddressHeaderPair(
preferredAddresses: readonly AddressInformation[]
}
| undefined {
if (allAddresses.length === 0) {
return undefined
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was the bug. By not returning undefined when we had no addresses, we would fail our if(x === undefined) check in the middleware, and not 404 correctly.

Copy link
Member

Choose a reason for hiding this comment

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

Awesome, nice catch.

@@ -147,8 +147,7 @@ describe('E2E - publicAPIRouter - Base PayID', function (): void {
const expectedErrorResponse = {
statusCode: 404,
error: 'Not Found',
message:
'Payment information for johndoe$127.0.0.1 in XRPL on TESTNET could not be found.',
message: 'Payment information for johndoe$127.0.0.1 could not be found.',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Update random test messages because I changed the 404 not found message.

// THEN we get back a 404 with the expected error response.
.expect(HttpStatus.NotFound, expectedErrorResponse, done)
// })
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the test that verifies we no longer have a bug in our header processing logic.

Copy link
Member

@dino-rodriguez dino-rodriguez left a comment

Choose a reason for hiding this comment

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

Nice, I'm happy we fixed this. LGTM!

Copy link
Collaborator

@0xASK 0xASK left a comment

Choose a reason for hiding this comment

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

LGTM, good find

@0xCLARITY 0xCLARITY merged commit e34a5a4 into master Jul 14, 2020
@0xCLARITY 0xCLARITY deleted the fix-payid-header-error branch July 14, 2020 20:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants