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

docs: fix regex under the pattern keyword #1335

Merged
merged 1 commit into from
Sep 27, 2023
Merged

Conversation

Imod7
Copy link
Contributor

@Imod7 Imod7 commented Sep 27, 2023

Issue

In 6 endpoints there is the following regex 'a-km-zA-HJ-NP-Z1-9{8,64}' under the pattern keyword. The regex intends to validate the user input for:

  • the blockId parameter of the block related endpoints and
  • the address parameter of the contracts endpoint

However, it is not working as expected hence is not allowing the user to input valid block heights or hashes.

Fix

In the block endpoints where the blockId is either a block height or a block hash, the regex was replaced by the following pattern :

^0[xX][0-9a-fA-F]{1,64}$|[0-9]{1,12}

This pattern should match either :

  • a hexadecimal string of total length of 66 digits. The pattern allows a string that starts with 0x or 0X and then its followed by 64 hexadecimal digits (0-9a-fA-F). This could work for the block hash.
  • an integer number of length 1 to 12 digits. This could work for the block height.

In the contracts endpoint, the pattern was removed.

Note

The replaced pattern in the blockId captures a lot of wrong inputs. However, it does not work 100% as expected (for example it ignores completely the length limit). I think this is a swagger issue since there are some open issues related to regex patterns not working correctly :

@Imod7 Imod7 requested a review from a team as a code owner September 27, 2023 12:41
Copy link
Member

@TarikGul TarikGul left a comment

Choose a reason for hiding this comment

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

Great Job. LGTM.

Copy link
Contributor

@bee344 bee344 left a comment

Choose a reason for hiding this comment

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

Nicely done

@Imod7 Imod7 merged commit fbdca75 into master Sep 27, 2023
14 checks passed
@Imod7 Imod7 deleted the domi-docs-fix-pattern branch September 27, 2023 17:19
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

Successfully merging this pull request may close these issues.

3 participants