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

add fallback value #663

Merged
merged 2 commits into from
Jun 27, 2024
Merged

Conversation

beatrizmaselli
Copy link
Contributor

@beatrizmaselli beatrizmaselli commented Jun 13, 2024

What problem is this solving?

Error when saving address in Ireland:

image

This API fails when the administrativeAreaLevel1 is null due to the schema validation:
image

How to test it?

Try add a new address at my account for ireland at the master and after at this workspace:

Workspace

How does this PR make you feel? 🔗

@beatrizmaselli beatrizmaselli requested a review from a team as a code owner June 13, 2024 16:06
@beatrizmaselli beatrizmaselli requested review from gvc, emersonlaurentino and GusGuerra and removed request for a team June 13, 2024 16:06
Copy link
Contributor

vtex-io-ci-cd bot commented Jun 13, 2024

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vmourac-vtex
Copy link
Contributor

Testes Realizados

Teste em ambiente sem Fix

Resultado: Erro replicado como esperado

Passo a passo:

  • Checkout do projeto store-graphql na branch master
  • Logar na loja e acessar um ambiente próprio via vtex login dunnesstoreqa e vtex use victormoura (no futuro pode ser mais claro usar um ambiente com nome relacionado ao PR, eg: vtex use storegraphqlpr663)
  • Linkar com o projeto local (na branch master) via vtex link -u -v

Acessar o Admin da Loja e submeter a seguinte query:

mutation SaveAddress($address: AddressInput!) {
  saveAddress(address: $address) {
    id
    cacheId
  }
}

Com os seguintes parâmetros:

{
  "address": {
    "addressType":"residential",
    "city":"Dublin",
    "complement":null,
    "country":"IRL",
    "receiverName":"Victor Cortez",
    "geoCoordinates":[],
    "neighborhood":null,
    "number":null,
    "postalCode":"D08 H6X3",
    "reference":null,
    "state":null,
    "street":"Teste GraphiQL - SEM Fix"}
}

O teste falha, como esperado, com a mensagem de erro:

{
  "data": null,
  "errors": [
    {
      "message": "Request failed with status code 400",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "vtex_storegraphql_2_170_2_saveAddress"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "message": "Request failed with status code 400",
          "name": "UserInputError",
          "status": 400,
          "code": "BAD_USER_INPUT",
          "level": "warn",
          "response": {
            "data": {
              "content": null,
              "status": "UserInputError",
              "message": "Error on schema validation:\n\n\tStringExpected: #/administrativeAreaLevel1"
            },
            "headers": {
              "content-length": "130",
              "content-type": "application/json; charset=utf-8",
              "date": "Mon, 24 Jun 2024 14:44:24 GMT",
              "server": "VTEX IO",
              "set-cookie": [
                "janus_sid=7fc219c9-8931-4646-9f75-e00ab6ef3f9e; expires=Thu, 27 Jun 2024 14:44:02 GMT; domain=portal.vtexcommercestable.com.br; path=/; samesite=lax"
              ],
              "x-envoy-decorator-operation": "profile-system.profile-system-stable.svc.cluster.local:80/*",
              "x-envoy-upstream-service-time": "316",
              "x-vtex-janus-router-backend-app": "storage-pf-vstable-eu-g1d",
              "x-vtex-operation-id": "0771d2f7-1c6b-4717-828e-d5f68e7d5a81",
              "x-request-id": "18a9a66e94fb4b93b470c296efcfedf8",
              "x-vtex-router-version": "9.15.7",
              "x-vtex-backend-status-code": "BadRequest",
              "x-vtex-backend-elapsed-time": "00:00:00.3894808",
              "x-vtex-router-elapsed-time": "00:00:00.4039510",
              "x-vtex-io-cluster-id": "prod-dj-iodev-eks-use1a-n1c"
            },
            "status": 400
          },
          "stacktrace": [
            "Error: Request failed with status code 400",
            "    at createError (/usr/local/app/node_modules/axios/lib/core/createError.js:16:15)",
            "    at settle (/usr/local/app/node_modules/axios/lib/core/settle.js:18:12)",
            "    at IncomingMessage.handleStreamEnd (/usr/local/app/node_modules/axios/lib/adapters/http.js:202:11)",
            "    at IncomingMessage.emit (events.js:208:15)",
            "    at endReadableNT (_stream_readable.js:1168:12)",
            "    at processTicksAndRejections (internal/process/task_queues.js:77:11)"
          ],
          "sensitive": {
            "config": {
              "baseURL": "http://portal.vtexcommercestable.com.br",
              "data": "{\"administrativeAreaLevel1\":null,\"addressName\":\"o6nwbpxrvl\",\"addressType\":\"residential\",\"countryCode\":\"IRL\",\"complement\":\"\",\"geoCoordinates\":[],\"locality\":\"Dublin\",\"localityAreaLevel1\":\"\",\"name\":\"o6nwbpxrvl\",\"nearly\":\"\",\"postalCode\":\"D08 H6X3\",\"route\":\"Teste GraphiQL - SEM Fix\",\"streetNumber\":\"\",\"receiverName\":\"Victor Cortez\"}",
              "headers": {
                "Accept": "application/json, text/plain, */*",
                "Content-Type": "application/json;charset=utf-8",
                "accept-encoding": "gzip",
                "user-agent": "[email protected]",
                "x-forwarded-host": "victormoura--dunnesstoresqa.myvtex.com",
                "x-vtex-tenant": "en-GB",
                "x-vtex-binding": "eyJpZCI6ImVjODkzZmEzLTM4ZGItNDE3Ni05ZDMwLTUzY2RkNGVmZTcyMCIsImxvY2FsZSI6ImVuLUdCIn0=",
                "x-vtex-locale": "en-GB",
                "x-vtex-operation-id": "0771d2f7-1c6b-4717-828e-d5f68e7d5a81",
                "x-vtex-segment": "eyJjYW1wYWlnbnMiOm51bGwsImNoYW5uZWwiOiIxIiwicHJpY2VUYWJsZXMiOm51bGwsInJlZ2lvbklkIjpudWxsLCJ1dG1fY2FtcGFpZ24iOm51bGwsInV0bV9zb3VyY2UiOm51bGwsInV0bWlfY2FtcGFpZ24iOm51bGwsImN1cnJlbmN5Q29kZSI6IkVVUiIsImN1cnJlbmN5U3ltYm9sIjoi4oKsIiwiY291bnRyeUNvZGUiOiJJUkwiLCJjdWx0dXJlSW5mbyI6ImVuLUdCIiwiYWRtaW5fY3VsdHVyZUluZm8iOiJlbi1VUyIsImNoYW5uZWxQcml2YWN5IjoicHVibGljIn0",
                "x-vtex-session": "eyJhbGciOiJFUzI1NiIsImtpZCI6IjZBNEI1MDE2RDYyOTYzNjk1OTE5QURENzkzQjdBRTU5RUZENzI4REIiLCJ0eXAiOiJqd3QifQ.eyJhY2NvdW50LmlkIjoiOTRlM2JhYWQtMmQxOC00ZDY4LThjNzYtMmY5ZTBjMmY2MDBiIiwiaWQiOiI3ZGNhNjBmZS03MGFiLTRmOTktOTg5Ny04ZDkyNDE3NzE5ZDkiLCJ2ZXJzaW9uIjo3LCJzdWIiOiJzZXNzaW9uIiwiYWNjb3VudCI6InNlc3Npb24iLCJleHAiOjE3MTk5Mjg1MTUsImlhdCI6MTcxOTIzNzMxNSwiaXNzIjoidG9rZW4tZW1pdHRlciIsImp0aSI6IjZjMGUyNGUyLThmNDEtNDE5Zi04MGU2LTQ5MDIwOWM1MzJmNSJ9.g0GrnA1XQsu3FU4Uh3KTpfCZunbPz-1rUjnJjY092El5aVWpd57kxYJZNsPk1CTVF-JmTUJsRLsdaUPG0eS55Q",
                "Content-Length": 328
              },
              "method": "post",
              "timeout": 5000,
              "url": "http://portal.vtexcommercestable.com.br/api/storage/profile-system/profiles/dc7716f7-cafb-4675-bbad-b4f14be60903/addresses",
              "metric": "profile-system-v2-createAddress",
              "params": {
                "an": "dunnesstoresqa"
              }
            },
            "request": {
              "finished": true,
              "method": "POST",
              "path": "/api/storage/profile-system/profiles/dc7716f7-cafb-4675-bbad-b4f14be60903/addresses?an=dunnesstoresqa"
            },
            "stack": "Error: Request failed with status code 400\n    at createError (/usr/local/app/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/usr/local/app/node_modules/axios/lib/core/settle.js:18:12)\n    at IncomingMessage.handleStreamEnd (/usr/local/app/node_modules/axios/lib/adapters/http.js:202:11)\n    at IncomingMessage.emit (events.js:208:15)\n    at endReadableNT (_stream_readable.js:1168:12)\n    at processTicksAndRejections (internal/process/task_queues.js:77:11)"
          }
        }
      },
      "positions": [
        76
      ],
      "name": "GraphQLError",
      "source": {
        "body": "mutation SaveAddress($address: vtex_storegraphql_2_170_2_AddressInput!) {\n  saveAddress: vtex_storegraphql_2_170_2_saveAddress(address: $address) {\n    id: vtex_storegraphql_2_170_2_id\n    cacheId: vtex_storegraphql_2_170_2_cacheId\n  }\n}\n",
        "name": "GraphQL request",
        "locationOffset": {
          "line": 1,
          "column": 1
        }
      },
      "operationId": "0771d2f7-1c6b-4717-828e-d5f68e7d5a81",
      "requestId": "957c4b378c7646c7b7a45b58c22cf6a2"
    }
  ]
}

Evidência:
erro-esperado

Erro na UI da Loja

Teste em ambiente com Fix aplicado:

Resultado: Correção validada com sucesso

Passo a passo:

  • Checkout do projeto store-graphql na branch add/fallback-administrativeAreaLevel1
  • Logar na loja e acessar um ambiente próprio via vtex login dunnesstoreqa e vtex use victormoura (no futuro pode ser mais claro usar um ambiente com nome relacionado ao PR, eg: vtex use storegraphqlpr663)
  • Linkar com o projeto local (na branch master) via vtex link -u -v

Acessar o Admin da Loja e submeter a seguinte query:

mutation SaveAddress($address: AddressInput!) {
  saveAddress(address: $address) {
    id
    cacheId
  }
}

Com os seguintes parâmetros:

{
  "address": {
    "addressType":"residential",
    "city":"Dublin",
    "complement":null,
    "country":"IRL",
    "receiverName":"Victor Cortez",
    "geoCoordinates":[],
    "neighborhood":null,
    "number":null,
    "postalCode":"D08 H6X3",
    "reference":null,
    "state":null,
    "street":"Teste GraphiQL - COM Fix"}
}

O teste não dá erros, como esperado, com a mensagem de retornada:

{
  "data": {
    "saveAddress": {
      "id": null,
      "cacheId": null
    }
  }
}

Evidência:
Teste Fix Aplicado Com Sucesso - GraphQL

Fix na UI da Loja

vmourac-vtex
vmourac-vtex previously approved these changes Jun 24, 2024
GusGuerra
GusGuerra previously approved these changes Jun 25, 2024
@vmourac-vtex vmourac-vtex merged commit 7e18c03 into master Jun 27, 2024
5 checks passed
@vmourac-vtex vmourac-vtex deleted the add/fallback-administrativeAreaLevel1 branch June 27, 2024 18:31
Copy link
Contributor

vtex-io-ci-cd bot commented Jun 27, 2024

Your PR has been merged! App is being published. 🚀
Version 2.170.3 → 2.170.4

After the publishing process has been completed (check #vtex-io-releases) and doing A/B tests with the new version, you can deploy your release by running:

vtex deploy [email protected]

After that your app will be updated on all accounts.

For more information on the deployment process check the docs. 📖

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