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

Stop generating optional data in company helper #1369

Merged
merged 2 commits into from
Sep 30, 2024

Conversation

Cruikshanks
Copy link
Member

https://eaflood.atlassian.net/browse/WATER-4600
https://eaflood.atlassian.net/browse/WATER-4645

We spotted when working on Updating all scenarios to use new points solution in water-abstraction-acceptance-tests that we were getting intermittent failures.

When we looked at the logs, we often saw.

[15:57:07.633] ERROR (12080): insert into "companies" ("company_number", "external_id", "id", "name", "organisation_type", "type") values ($1, $2, $3, $4, $5, $6) returning * - duplicate key value violates unique constraint "unique_external_id"
    err: {
      "type": "UniqueViolationError",
      "message": "insert into \"companies\" (\"company_number\", \"external_id\", \"id\", \"name\", \"organisation_type\", \"type\") values ($1, $2, $3, $4, $5, $6) returning * - duplicate key value violates unique constraint \"unique_external_id\"",

When we checked the CompanyHelper, we spotted that we were populating fields, including external_id, that were not required. The idea of the helpers is to populate the minimum needed: anything is on the caller to provide. If we don't need to populate these fields, we stand a better chance of avoiding failures due to unique constraint clashes.

https://eaflood.atlassian.net/browse/WATER-4600
https://eaflood.atlassian.net/browse/WATER-4645

We spotted when working on [Updating all scenarios to use new points solution](DEFRA/water-abstraction-acceptance-tests#137) in **water-abstraction-acceptance-tests** that we were getting intermittent failures.

When we looked at the logs we often saw

```text
[15:57:07.633] ERROR (12080): insert into "companies" ("company_number", "external_id", "id", "name", "organisation_type", "type") values ($1, $2, $3, $4, $5, $6) returning * - duplicate key value violates unique constraint "unique_external_id"
    err: {
      "type": "UniqueViolationError",
      "message": "insert into \"companies\" (\"company_number\", \"external_id\", \"id\", \"name\", \"organisation_type\", \"type\") values ($1, $2, $3, $4, $5, $6) returning * - duplicate key value violates unique constraint \"unique_external_id\"",
```

When we checked the `CompanyHelper` we spotted that we were populating fields, including `external_id` which are not actually required. The idea of the helpers is to populate the minimum needed, any thing is on the caller to provide. If we don't need to populate these fields, we stand a better chance of avoiding failures due to unique constraint clashes.
@Cruikshanks Cruikshanks marked this pull request as ready for review September 28, 2024 16:13
@Cruikshanks Cruikshanks merged commit 08c984c into main Sep 30, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the stop-generating-optional-data-company-helper branch September 30, 2024 13:39
@Cruikshanks Cruikshanks self-assigned this Oct 10, 2024
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.

2 participants