Skip to content

Conversation

@bobdev-94
Copy link
Contributor

@bobdev-94 bobdev-94 commented Sep 16, 2025

Issue: bcgov/entity#30397

Description of changes:

  • Issue on the Dev
Screenshot 2025-09-16 at 3 24 12 PM
  • Fixed.
Screenshot 2025-09-16 at 3 27 03 PM Screenshot 2025-09-16 at 3 27 47 PM Screenshot 2025-09-16 at 3 28 48 PM

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the namex license (Apache 2.0).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes phone number validation by replacing the string punctuation removal approach with a more robust regex-based solution that removes all non-digit characters.

Key changes:

  • Replaces string.maketrans with re.sub for phone number cleaning
  • Changes from removing only punctuation to removing all non-digit characters

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@severinbeauvais severinbeauvais left a comment

Choose a reason for hiding this comment

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

Namex API has version number somewhere. Can you please update it?

Eg: https://namex-dev.apps.silver.devops.gov.bc.ca/api/v1/meta/info

Copy link
Collaborator

@severinbeauvais severinbeauvais left a comment

Choose a reason for hiding this comment

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

LGTM but wait for more reviews and consider CP's suggestion.

@gitguardian
Copy link

gitguardian bot commented Sep 16, 2025

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
9442085 Triggered Generic Password 05ee813 api/.env.sample View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@severinbeauvais
Copy link
Collaborator

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Bobby, this is referring to a file you didn't change, but that was picked up in your rebase. Anyway, I think it's nothing that needs to be changed in your PR.

cc: @bolyachevets , looks like this was from your commit yesterday (#1883 and #1884).

@bolyachevets
Copy link
Collaborator

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Bobby, this is referring to a file you didn't change, but that was picked up in your rebase. Anyway, I think it's nothing that needs to be changed in your PR.

cc: @bolyachevets , looks like this was from your commit yesterday (#1883 and #1884).

it is a generic placeholder username postgres/postgres for unit tests using local db - nothing to worry about

Copy link

@loneil loneil left a comment

Choose a reason for hiding this comment

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

Not really anything to add other than the copilot notes (though the string import removal looks to be fine). First time looking at this repo myself as well.

Maybe could additionally be a good idea to extract the duplicate regex call to some normalize_phone_number helper function, then could be good to have a targetted unit test that tries out all the phone number options like

@pytest.mark.parametrize("input_phone,expected", [
    ("(555) 123-4567", "5551234567"),
    ("+1-555-123-4567", "15551234567"),
    ("555.123.4567", "5551234567"),
    ("555 123 4567", "5551234567"),
    ("5551234567", "5551234567"),
    ("", ""),
    (None, ""),
])
def test_normalize_phone_number(input_phone, expected):
    result = normalize_phone_number(input_phone or "")
    assert result == expected

Copy link
Collaborator

@severinbeauvais severinbeauvais left a comment

Choose a reason for hiding this comment

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

The code changes look good to me.

@severinbeauvais
Copy link
Collaborator

@bobdev-94 , what do you think about create a unit test like Lucas suggested?

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 8, 2025

Copy link
Collaborator

@severinbeauvais severinbeauvais left a comment

Choose a reason for hiding this comment

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

LGTM!

But we will need a review from someone on the Names Team.

@severinbeauvais
Copy link
Collaborator

@stevenc987 , @eve-git , @mengdong19 Could you guys review this when you have a moment, please?

@severinbeauvais severinbeauvais merged commit 7736593 into bcgov:main Oct 28, 2025
5 of 6 checks passed
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.

6 participants