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

Typescript improvements #2299

Open
wants to merge 4 commits into
base: development/8.2
Choose a base branch
from

Conversation

williamlardier
Copy link
Contributor

@williamlardier williamlardier commented Feb 21, 2025

Improve TS:

  • Auth types are fixed as they were inconsistent. We still have a mix of 4 possible types as output whtn doing auth (authinfo, authv4 info, authv2 or public user).
  • Old style _ prefix to define private variable in TS classes was removed: this is not following the TS standard. More file might still be affected.
  • Data models for both Bucket and Objects were standardized to avoid using any.
    • This allowed to find a limitation in the createBucket function in the mongo client interface.

@bert-e
Copy link
Contributor

bert-e commented Feb 21, 2025

Hello williamlardier,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@bert-e
Copy link
Contributor

bert-e commented Feb 21, 2025

Incorrect fix version

The Fix Version/s in issue ARSN-462 contains:

  • None

Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:

  • 8.2.4

Please check the Fix Version/s of ARSN-462, or the target
branch of this pull request.

@williamlardier williamlardier force-pushed the improvement/ARSN-462 branch 4 times, most recently from 0b32365 to 28fd751 Compare February 24, 2025 16:21
@williamlardier williamlardier marked this pull request as ready for review February 24, 2025 16:21
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 97.42268% with 5 lines in your changes missing coverage. Please review.

Project coverage is 68.75%. Comparing base (9ae954c) to head (9925cc3).

Files with missing lines Patch % Lines
lib/models/BucketPolicy.ts 87.50% 2 Missing ⚠️
lib/auth/auth.ts 80.00% 1 Missing ⚠️
lib/models/LifecycleConfiguration.ts 50.00% 1 Missing ⚠️
lib/models/ReplicationConfiguration.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           development/8.2    #2299      +/-   ##
===================================================
+ Coverage            68.72%   68.75%   +0.03%     
===================================================
  Files                  216      216              
  Lines                17462    17454       -8     
  Branches              3646     3629      -17     
===================================================
  Hits                 12000    12000              
+ Misses                5458     5450       -8     
  Partials                 4        4              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

lib/auth/auth.ts Outdated
if (res.params.version === 2) {
// @ts-ignore
return vault!.authenticateV2Request(res.params, requestContexts, cb);
res.params!.log = log;
Copy link
Contributor

Choose a reason for hiding this comment

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

do you know why Typescript is not able to infer the type here?
As far as I understand, extractParams() return either AuthV2RequestParams, AuthV4RequestParams or AuthInfo. Since the AuthInfo case is handle, TS should be able to deduce this will be either AuthV2RequestParams or AuthV4RequestParams...

Maybe this is due to the "optional" params (params?) in result of extractParams?
And the return type should be better type to either return an error without params, or params with null error: so that type deduction can work its magic, and we don't need type coercion...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the PR, I created a new type that allows TS to understand that params is defined if err is null.

@bert-e
Copy link
Contributor

bert-e commented Mar 5, 2025

Incorrect fix version

The Fix Version/s in issue ARSN-462 contains:

  • None

Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:

  • 8.2.5

Please check the Fix Version/s of ARSN-462, or the target
branch of this pull request.

value: newBucketMD,
value: {
...newBucketMD,
quotaMax: new Long(newBucketMD.quotaMax || '0'),
Copy link
Contributor

Choose a reason for hiding this comment

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

should have an associated test, to ensure we can indeed properly create buckets with very large quotas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Creating a bucket with a quota is not possible today, this is only to enforce the right type in the DB, as it fails the type validation. Having large quotas is already tested in the proper routes, and this Long conversion is (indirectly) tested when we create buckets, when we test that we can properly pass a BucketInfo object.

Do we still want such test?

@williamlardier
Copy link
Contributor Author

I added a commit to fix the types of the loggers and fix a conflict with Vault.ts.

@williamlardier williamlardier force-pushed the improvement/ARSN-462 branch 2 times, most recently from 2ce22e9 to 7e7674f Compare March 5, 2025 15:29
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