keyshade-xyz / keyshade

Realtime secret and configuration management tool, with the best in class security and seamless integration support
https://keyshade.xyz
Mozilla Public License 2.0
208 stars 105 forks source link

fix(api,api-client): Add environmentSlug in multiple places across the variable module #468

Closed Nil2000 closed 1 month ago

Nil2000 commented 1 month ago

Description

Add environmentSlug in multiple places across the variable module

Fixes #431

Dependencies

Mention any dependencies/packages used

Future Improvements

Mention any improvements to be done in future related to any file/feature

Mentions

Mention and tag the people

Screenshots of relevant screens

Add screenshots of relevant screens

Developer's checklist

If changes are made in the code:

Documentation Update

codiumai-pr-agent-free[bot] commented 1 month ago

PR Reviewer Guide πŸ”

⏱️ Estimated effort to review: 3 πŸ”΅πŸ”΅πŸ”΅βšͺβšͺ
πŸ§ͺ PR contains tests
πŸ”’ No security concerns identified
⚑ Key issues to review

Possible Typo
There's a potential typo in the `enivronment` property name at line 19. It should be `environment`. Possible Typo
There's a potential typo in the `enivronment` property name at line 19. It should be `environment`. Possible Typo
There's a potential typo in the `enivronment` property name at line 113. It should be `environment`.
codiumai-pr-agent-free[bot] commented 1 month ago

PR Code Suggestions ✨

CategorySuggestion                                                                                                                                    Score
Best practice
Use a constant or enum for field names to improve code maintainability ___ **Consider using a constant or enum for the 'slug' property name to improve
maintainability and reduce the risk of typos.** [apps/api/src/variable/service/variable.service.ts [124-128]](https://github.com/keyshade-xyz/keyshade/pull/468/files#diff-db1895137a9c036373abefb8c924150d4f2022fd6d4f5271cc6c95c443bf01cfR124-R128) ```diff environment: { select: { - slug: true + [EnvironmentFields.SLUG]: true } }, ``` - [ ] **Apply this suggestion**
Suggestion importance[1-10]: 7 Why:
7
Maintainability
Extract repeated selection object into a constant to reduce duplication ___ **Consider extracting the repeated environment selection object into a reusable
constant to reduce code duplication.** [apps/api/src/variable/service/variable.service.ts [253-257]](https://github.com/keyshade-xyz/keyshade/pull/468/files#diff-db1895137a9c036373abefb8c924150d4f2022fd6d4f5271cc6c95c443bf01cfR253-R257) ```diff -environment: { - select: { - slug: true - } -}, +environment: ENVIRONMENT_SELECT_OBJECT, ``` - [ ] **Apply this suggestion**
Suggestion importance[1-10]: 7 Why:
7
Possible bug
βœ… Correct the spelling of a property name to ensure accurate typing ___
Suggestion Impact:The typo in the property name 'enivronment' was corrected to 'environment', as suggested. code diff: ```diff - enivronment: { + environment: { ```
___ **Fix the typo in the 'enivronment' property name to 'environment' to ensure correct
typing and avoid potential bugs.** [packages/api-client/src/types/variable.types.d.ts [19-21]](https://github.com/keyshade-xyz/keyshade/pull/468/files#diff-a5cc3a8d29899e24783200cd22d84f671e390b3fb0efc276f85840fc6d5ed0f3R19-R21) ```diff -enivronment: { +environment: { slug: string } ``` - [ ] **Apply this suggestion**
Suggestion importance[1-10]: 7 Why:
7
Possible issue
βœ… Fix a typo in a test assertion to ensure it correctly checks the property ___
Suggestion Impact:The typo in the property name 'enivronment' was corrected to 'environment' in the test assertion, as suggested. code diff: ```diff - expect(variable.data.versions[0].enivronment.slug).toBe(environment.slug) + expect(variable.data.versions[0].environment.slug).toBe(environment.slug) ```
___ **Correct the typo in the 'enivronment' property name to 'environment' to match the
corrected type definition and ensure the test passes.** [packages/api-client/tests/variable.spec.ts [113]](https://github.com/keyshade-xyz/keyshade/pull/468/files#diff-44c34cd8f05455a5232b41d07eb6770f8a7c179bd2302fff90ba968c44690de2R113-R113) ```diff -expect(variable.data.versions[0].enivronment.slug).toBe(environment.slug) +expect(variable.data.versions[0].environment.slug).toBe(environment.slug) ``` - [ ] **Apply this suggestion**
Suggestion importance[1-10]: 7 Why:
7

πŸ’‘ Need additional feedback ? start a PR chat

Nil2000 commented 1 month ago

Hi @rajdip-b , Require some help here.

Should this be environment-2-0 since we are passing environment2.id in environmentId field?

image

https://github.com/keyshade-xyz/keyshade/blob/beaf8765290d7ca62da6b611ee85539e23d342ea/apps/api/src/variable/variable.e2e.spec.ts#L176-L190

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 48.01%. Comparing base (ce50743) to head (7f83d64). Report is 183 commits behind head on develop.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #468 +/- ## ============================================ - Coverage 91.71% 48.01% -43.71% ============================================ Files 111 105 -6 Lines 2510 2743 +233 Branches 469 415 -54 ============================================ - Hits 2302 1317 -985 - Misses 208 1426 +1218 ``` | [Flag](https://app.codecov.io/gh/keyshade-xyz/keyshade/pull/468/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keyshade-xyz) | Coverage Ξ” | | |---|---|---| | [api-e2e-tests](https://app.codecov.io/gh/keyshade-xyz/keyshade/pull/468/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keyshade-xyz) | `48.01% <ΓΈ> (-43.71%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keyshade-xyz#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Nil2000 commented 1 month ago

image In places where we are selecting both environmentId and environment slug, its better to include it by using environment.id and environment.slug:

      environment: {
        id: true
        slug: true
      }

Ok made these changes but did you notice about the environment2 test mentioned earlier? It is still coming.

image

Nil2000 commented 1 month ago

This step is failing: https://github.com/keyshade-xyz/keyshade/actions/runs/11092075120/job/30816652494?pr=468#step:10:486

Yeah already mentioned the issue this is always pointing to environment-1-0 slug or Environment 1 though I have pointed that to environment2. I am unable to get why this is happening. Can it be issue at the mapping part?

rajdip-b commented 1 month ago

@Nil2000 sorry about the delay, i have fixed the error. I would just need you to remove environmentId and have environment.id everywhere like i mentioned earlier.

rajdip-b commented 1 month ago

https://github.com/keyshade-xyz/keyshade/issues/486

This is a related issue that you can pick up.

rajdip-b commented 1 month ago

@Nil2000 can you please add this change I mentioned?

@Nil2000 sorry about the delay, i have fixed the error. I would just need you to remove environmentId and have environment.id everywhere like i mentioned earlier.

Nil2000 commented 1 month ago

@Nil2000 can you please add this change I mentioned?

@Nil2000 sorry about the delay, i have fixed the error. I would just need you to remove environmentId and have environment.id everywhere like i mentioned earlier.

Working on it. Would be done by today

Nil2000 commented 1 month ago

@rajdip-b The test issue is still present image

rajdip-b commented 3 weeks ago

:tada: This PR is included in version 2.6.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: