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

fix: Revert breaking change for incoming token creation reqs #2084

Merged
merged 1 commit into from
Sep 23, 2022

Conversation

thomasheartman
Copy link
Contributor

What

This change reverts the spec change to create-api-token-schema that was introduced in 97c2b3c

That commit changed the endpoint from allowing any string to only allowing strings that match the values of the ApiTokenType value.

Why

Because we already validate this on the backend, I didn't think it would break anything. However, because OpenAPI enums are case sensitive (and do not currently support anything else), it did break the API. (stack overflow post that explains how this works)

Of note

This should have been caught by the tests, but it didn't show up until it was merged to the main branch. I think it might be worth looking into how we do the PR testing.

## What

This change reverts the spec change to create-api-token-schema that
was introduced in 97c2b3c

That commit changed the endpoint from allowing any string to only
allowing strings that match the values of the ApiTokenType value.

## Why

Because we already validate this on the backend, I didn't think it
would break anything. However, because OpenAPI enums are case
sensitive (and do not currently support anything else), it _did_ break
the API. ([stack overflow post that explains how this
works](https://stackoverflow.com/questions/60772786/case-insensitive-string-parameter-in-schema-of-openapi))

## Of note

This should have been caught by the tests, but it didn't show up until
it was merged to the main branch. I think it might be worth looking
into how we do the PR testing.
@vercel
Copy link

vercel bot commented Sep 23, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Ignored Deployments
Name Status Preview Updated
unleash ⬜️ Ignored (Inspect) Sep 23, 2022 at 1:36PM (UTC)
unleash-docs ⬜️ Ignored (Inspect) Sep 23, 2022 at 1:36PM (UTC)
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Sep 23, 2022 at 1:36PM (UTC)

@thomasheartman thomasheartman enabled auto-merge (squash) September 23, 2022 13:39
@github-actions
Copy link

Coverage report

❌ An unexpected error occurred. For more details, check console

Error: The process '/usr/local/bin/yarn' failed with exit code 1
St.
Category Percentage Covered / Total
🟢 Statements
88.29% (-3.09% 🔻)
7063/8000
🟡 Branches 78.63% 1100/1399
🟢 Functions
81.95% (-4.27% 🔻)
1989/2427
🟢 Lines
88.58% (-2.72% 🔻)
6548/7392

⚠️ Details were not displayed: the report size has exceeded the limit.

Test suite run failed

Failed tests: 1/1165. Failed suites: 1/192.
  ● creates new ADMIN token should fix casing

    expected 201 "Created", got 400 "Bad Request"

      78 |         })
      79 |         .set('Content-Type', 'application/json')
    > 80 |         .expect(201)
         |          ^
      81 |         .expect((res) => {
      82 |             expect(res.body.username).toBe('default-admin');
      83 |             expect(res.body.type).toBe('admin');

      at Object.expect (src/test/e2e/api/admin/api-token.e2e.test.ts:80:10)
          at runMicrotasks (<anonymous>)
      ----
      at Test._assertStatus (node_modules/supertest/lib/test.js:252:14)
      at node_modules/supertest/lib/test.js:306:17
      at Test._assertFunction (node_modules/supertest/lib/test.js:285:13)
      at Test.assert (node_modules/supertest/lib/test.js:164:23)
      at Server.localAssert (node_modules/supertest/lib/test.js:120:14)

Report generated by 🧪jest coverage report action from e01ef28

Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

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

Okay, tests are broken here but not because of this, because of the build so I'm slapping a LGTM on this

Copy link
Contributor

@chriswk chriswk left a comment

Choose a reason for hiding this comment

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

LGTM

@chriswk chriswk merged commit f131d5a into main Sep 23, 2022
@chriswk chriswk deleted the fix/openapi-api-token-breakage branch September 23, 2022 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants