Skip to content

Conversation

@shirady
Copy link
Contributor

@shirady shirady commented Dec 2, 2025

Describe the Problem

Currently, there are many calls to system_store in functions related to IAM.

Explain the Changes

  1. Reduce the calls to system_store, mainly where it was to get the requesting_account in the file accountspace_nb.js.

Issues:

List of GAPs:

  • I think we need to move the create_user inside the account_server so we would have the req.account access and keep this file with small functionality.
  • Planned to work on the files: account_server and account_utils as well.
  • There is code duplication that I found; probably we can reduce more in the future.

Testing Instructions:

I rerun the API tests to make sure it doesn't break.

Automatic test

Containerized

  1. Use the guide "Run Tests From coretest Locally" (link) for running the core tests.
  2. Run first tab: docker run -p 5432:5432 -e POSTGRESQL_ADMIN_PASSWORD=noobaa quay.io/sclorg/postgresql-15-c9s
  3. Run second tab: NOOBAA_LOG_LEVEL=all ./node_modules/.bin/mocha src/test/integration_tests/api/iam/test_iam_basic_integration.js
  • Doc added/updated
  • Tests added

Summary by CodeRabbit

  • Refactor
    • Simplified internal account/user handling and streamlined backend request flow by removing redundant internal argument passing.
    • Consolidated ownership/resource resolution and cleaned up related labels and comments.
    • No changes to public APIs, method signatures, or any user-visible behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@shirady shirady self-assigned this Dec 2, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 2, 2025

Walkthrough

Replaced in-file account lookups with direct use of account_sdk.requesting_account across user, access-key, tag, and policy methods in AccountSpaceNB; removed passing requesting_account to RPC client calls (RPCs now receive only a params object) and switched ownership wrapping to requesting_account._id.

Changes

Cohort / File(s) Summary
AccountSpaceNB user/access-key/tag/policy updates
src/sdk/accountspace_nb.js
Replaced system_store.get_account_by_email(...) with account_sdk.requesting_account across user methods (create_user, get_user, update_user, delete_user, list_users), access-key, tag (tag/untag/list), and policy (put/get/delete/list user policies) methods. Removed passing requesting_account to RPC client calls so RPCs receive only a single params object. Switched ownership/account wrapping to use requesting_account._id (no string conversions). Minor header/comment formatting adjustments.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify all RPC call sites were updated to remove the extra requesting_account argument.
  • Confirm consistent use of requesting_account._id (type correctness; no unintended toString changes).
  • Review create_user changes (owner assignment and removal of default_resource logic).
  • Sanity-check parameter shapes for access-key, tag, and policy RPC calls.

Possibly related PRs

Suggested reviewers

  • aayushchouhan09
  • naveenpaul1

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main change: removing unnecessary system_store calls from IAM-related functions in accountspace_nb.js, which aligns with the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d6808e3 and 4ddc131.

📒 Files selected for processing (1)
  • src/sdk/accountspace_nb.js (3 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9330
File: src/sdk/accountspace_nb.js:30-30
Timestamp: 2025-12-04T10:55:08.659Z
Learning: In src/sdk/accountspace_nb.js, account_sdk.requesting_account comes from RPC serialization, so requesting_account._id is already a string (not an ObjectId). This differs from system_store.get_account_by_email() which returns accounts with ObjectId._id references. Therefore, no .toString() conversion is needed when using account_sdk.requesting_account._id in accountspace_nb.js.
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.
📚 Learning: 2025-12-04T10:55:08.659Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9330
File: src/sdk/accountspace_nb.js:30-30
Timestamp: 2025-12-04T10:55:08.659Z
Learning: In src/sdk/accountspace_nb.js, account_sdk.requesting_account comes from RPC serialization, so requesting_account._id is already a string (not an ObjectId). This differs from system_store.get_account_by_email() which returns accounts with ObjectId._id references. Therefore, no .toString() conversion is needed when using account_sdk.requesting_account._id in accountspace_nb.js.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-19T15:03:42.260Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9291
File: src/server/common_services/auth_server.js:548-554
Timestamp: 2025-11-19T15:03:42.260Z
Learning: In src/server/common_services/auth_server.js, account objects are loaded directly from system_store (e.g., system_store.data.get_by_id()), so account.owner is an object ID reference with an ._id property, not a string. This differs from s3_rest.js where account.owner is a string due to RPC serialization.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-13T07:56:23.620Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9281
File: src/server/system_services/account_server.js:1053-1058
Timestamp: 2025-11-13T07:56:23.620Z
Learning: In noobaa-core, account_server.js is only used in containerized deployments, not in NSFS/NC deployments. NSFS/NC deployments have separate account management code in src/manage_nsfs/ directory. Therefore, account_server.js only processes accounts from account_schema.js where owner is an objectid reference, never from nsfs_account_schema.js where owner is a string.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-12T04:55:42.193Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-08-08T13:08:38.361Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9182
File: src/server/system_services/bucket_server.js:1324-1327
Timestamp: 2025-08-08T13:08:38.361Z
Learning: In src/server/system_services/bucket_server.js, the update_all_buckets_default_pool(req) handler expects req.rpc_params.pool_name to be a plain string (not a SensitiveString wrapper), so calling .unwrap() is not needed there.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-08-08T13:12:46.728Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9182
File: src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js:9-17
Timestamp: 2025-08-08T13:12:46.728Z
Learning: In upgrade script src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js for noobaa-core, rely on structural detection (e.g., pool.mongo_info, and resource_type === 'INTERNAL') with name-prefix fallback for removing legacy mongo/internal pools, instead of depending solely on config.INTERNAL_STORAGE_POOL_NAME or config.DEFAULT_POOL_NAME. Handle multi-system stores and remove all matching pools in one change.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-18T07:00:17.653Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_bucket_policy_utils.js:357-368
Timestamp: 2025-11-18T07:00:17.653Z
Learning: In NooBaa codebase, account.name is always a SensitiveString instance, so calling account.name.unwrap() is safe without defensive type checks in functions like get_bucket_policy_principal_arn in src/endpoint/s3/s3_bucket_policy_utils.js.

Applied to files:

  • src/sdk/accountspace_nb.js
🧬 Code graph analysis (1)
src/sdk/accountspace_nb.js (2)
src/server/system_services/account_server.js (27)
  • params (328-328)
  • params (691-691)
  • params (955-955)
  • requesting_account (1208-1208)
  • requesting_account (1230-1230)
  • requesting_account (1279-1279)
  • requesting_account (1296-1296)
  • requesting_account (1324-1324)
  • requesting_account (1355-1355)
  • requesting_account (1368-1368)
  • requesting_account (1396-1396)
  • requesting_account (1413-1413)
  • requesting_account (1434-1434)
  • requesting_account (1476-1476)
  • requesting_account (1505-1505)
  • requesting_account (1527-1527)
  • requesting_account (1556-1556)
  • requesting_account (1570-1570)
  • requesting_account (1589-1589)
  • account_email_wrapped (1280-1280)
  • account_email_wrapped (1435-1435)
  • account_email_wrapped (1477-1477)
  • account_email_wrapped (1506-1506)
  • account_util (25-25)
  • account_util (53-53)
  • req (134-134)
  • req (396-396)
src/util/account_util.js (1)
  • req (680-680)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: run-package-lock-validation
  • GitHub Check: Build Noobaa Image
  • GitHub Check: run-jest-unit-tests
🔇 Additional comments (5)
src/sdk/accountspace_nb.js (5)

53-72: LGTM! Correctly removed redundant await keywords.

The removal of await from these methods is correct, as they simply forward calls to the RPC client without additional logic. This makes the code cleaner and slightly more efficient by avoiding unnecessary promise unwrapping and re-wrapping.


78-98: LGTM! Access key methods correctly simplified.

The removal of await from access key methods follows the same correct pattern as the user methods. All methods now cleanly forward to the RPC client.


104-114: LGTM! Tag methods correctly simplified.

The tag methods follow the same clean pattern of removing redundant await keywords and directly returning RPC calls.


120-134: LGTM! Policy methods correctly simplified.

The policy methods complete the consistent refactoring pattern across the entire file, cleanly forwarding to RPC handlers without redundant await keywords.


28-51: LGTM! Simplified account access using RPC-serialized account.

The refactoring correctly uses account_sdk.requesting_account instead of system_store, eliminating unnecessary database calls. Since requesting_account._id comes from RPC serialization, it is already a string and requires no .toString() conversion. The RPC call is properly simplified to pass only the request object, with the handler accessing the requesting account from req.account.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/sdk/accountspace_nb.js (1)

36-62: Bug risk: default_resource.name no longer valid after removing system_store lookup

Now that requesting_account comes directly from account_sdk.requesting_account (the RPC-serialized account), requesting_account.default_resource is already a string (pool name) rather than a pool object. Using .name here will yield undefined and either break CreateUser or cause the server to fall back to an unintended default pool.

Consider updating the request construction to pass the name directly:

-        const req = {
-                name: account_name,
-                email: account_name,
-                has_login: false,
-                s3_access: true,
-                allow_bucket_creation: true,
-                owner: requesting_account._id.toString(),
-                iam_path: params.iam_path,
-                roles: ['admin'],
-                // TODO: default_resource remove
-                default_resource: requesting_account.default_resource.name,
-            };
+        const req = {
+            name: account_name,
+            email: account_name,
+            has_login: false,
+            s3_access: true,
+            allow_bucket_creation: true,
+            owner: requesting_account._id.toString(),
+            iam_path: params.iam_path,
+            roles: ['admin'],
+            // `requesting_account.default_resource` is already the pool name from RPC serialization
+            default_resource: requesting_account.default_resource,
+        };

This keeps the behavior consistent with what create_account expects (default_resource as a pool name string) while still avoiding any direct system_store lookup.

🧹 Nitpick comments (2)
src/util/account_util.js (1)

324-332: Returning the account object here is correct and useful

The added return account; keeps existing error semantics while allowing callers (e.g., in account_server.js) to avoid a second system_store lookup. The implementation here looks good.

You may optionally update validate_and_return_requested_account() to use the returned value instead of calling system_store.get_account_by_email() again to reduce duplication and race surface.

src/server/system_services/account_server.js (1)

1227-1281: Centralizing IAM user lookup via _check_if_account_exists looks correct

The refactor in:

  • update_user (Lines 1227–1264),
  • delete_user (Lines 1268–1281),
  • tag_user (Lines 1422–1460),
  • untag_user (Lines 1462–1487), and
  • list_user_tags (Lines 1489–1515)

to use account_util._check_if_account_exists() and consume its returned requested_account is structurally sound. It:

  • Removes duplicate system_store.get_account_by_email() logic,
  • Standardizes the “no such entity” error path and messaging, and
  • Keeps all ownership and root/IAM distinctions enforced by the existing helper checks.

As a follow-up, you could consider whether some of these flows (especially where you recompute the same email_wrapped and run the same root/ownership checks) could reuse validate_and_return_requested_account() to further reduce repetition, but functionally this change is good.

Also applies to: 1422-1515

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89f64d8 and 9d097bd.

📒 Files selected for processing (3)
  • src/sdk/accountspace_nb.js (4 hunks)
  • src/server/system_services/account_server.js (5 hunks)
  • src/util/account_util.js (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9182
File: src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js:9-17
Timestamp: 2025-08-08T13:12:46.728Z
Learning: In upgrade script src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js for noobaa-core, rely on structural detection (e.g., pool.mongo_info, and resource_type === 'INTERNAL') with name-prefix fallback for removing legacy mongo/internal pools, instead of depending solely on config.INTERNAL_STORAGE_POOL_NAME or config.DEFAULT_POOL_NAME. Handle multi-system stores and remove all matching pools in one change.
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9291
File: src/server/common_services/auth_server.js:548-554
Timestamp: 2025-11-19T15:03:42.260Z
Learning: In src/server/common_services/auth_server.js, account objects are loaded directly from system_store (e.g., system_store.data.get_by_id()), so account.owner is an object ID reference with an ._id property, not a string. This differs from s3_rest.js where account.owner is a string due to RPC serialization.
📚 Learning: 2025-11-19T15:03:42.260Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9291
File: src/server/common_services/auth_server.js:548-554
Timestamp: 2025-11-19T15:03:42.260Z
Learning: In src/server/common_services/auth_server.js, account objects are loaded directly from system_store (e.g., system_store.data.get_by_id()), so account.owner is an object ID reference with an ._id property, not a string. This differs from s3_rest.js where account.owner is a string due to RPC serialization.

Applied to files:

  • src/util/account_util.js
  • src/sdk/accountspace_nb.js
  • src/server/system_services/account_server.js
📚 Learning: 2025-11-13T07:56:23.620Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9281
File: src/server/system_services/account_server.js:1053-1058
Timestamp: 2025-11-13T07:56:23.620Z
Learning: In noobaa-core, account_server.js is only used in containerized deployments, not in NSFS/NC deployments. NSFS/NC deployments have separate account management code in src/manage_nsfs/ directory. Therefore, account_server.js only processes accounts from account_schema.js where owner is an objectid reference, never from nsfs_account_schema.js where owner is a string.

Applied to files:

  • src/util/account_util.js
  • src/sdk/accountspace_nb.js
  • src/server/system_services/account_server.js
📚 Learning: 2025-11-12T04:55:42.193Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.

Applied to files:

  • src/sdk/accountspace_nb.js
  • src/server/system_services/account_server.js
📚 Learning: 2025-12-01T13:35:12.469Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9327
File: src/endpoint/iam/ops/iam_get_user.js:32-32
Timestamp: 2025-12-01T13:35:12.469Z
Learning: In AWS IAM GetUser API responses, the Tags field is omitted entirely when a user has no tags. The field only appears in the response after a user has been tagged, and disappears again when all tags are removed. This differs from some AWS APIs that return empty arrays for absent collections.

Applied to files:

  • src/server/system_services/account_server.js
🧬 Code graph analysis (1)
src/sdk/accountspace_nb.js (1)
src/server/system_services/account_server.js (19)
  • requesting_account (1208-1208)
  • requesting_account (1228-1228)
  • requesting_account (1269-1269)
  • requesting_account (1285-1285)
  • requesting_account (1313-1313)
  • requesting_account (1344-1344)
  • requesting_account (1357-1357)
  • requesting_account (1385-1385)
  • requesting_account (1402-1402)
  • requesting_account (1423-1423)
  • requesting_account (1464-1464)
  • requesting_account (1491-1491)
  • requesting_account (1519-1519)
  • requesting_account (1548-1548)
  • requesting_account (1562-1562)
  • requesting_account (1581-1581)
  • params (328-328)
  • params (691-691)
  • params (955-955)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: run-jest-unit-tests
  • GitHub Check: run-package-lock-validation
  • GitHub Check: Build Noobaa Image
🔇 Additional comments (1)
src/sdk/accountspace_nb.js (1)

64-161: Consistent use of account_sdk.requesting_account looks good; verify call contracts

The rest of the methods now consistently derive requesting_account from account_sdk.requesting_account and pass it into the corresponding RPC calls. That aligns with the PR goal of avoiding extra system_store lookups.

Please double-check that:

  • account_sdk.requesting_account is always populated with the same logical account as req.account on the server side for these IAM flows, and
  • The second argument to rpc_client.account.* is still treated as an options/context object and not relied on for anything now removed from system_store.

End-to-end IAM integration tests (especially around user management and access key APIs) should catch any remaining mismatches.

@shirady shirady force-pushed the iam-remove-system-store-calls branch from 9d097bd to 5f59a40 Compare December 2, 2025 13:53
@shirady shirady marked this pull request as draft December 3, 2025 14:02
@shirady shirady force-pushed the iam-remove-system-store-calls branch from 5f59a40 to c8167ee Compare December 4, 2025 10:29
@shirady shirady marked this pull request as ready for review December 4, 2025 10:31
@pull-request-size pull-request-size bot added size/L and removed size/M labels Dec 4, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f59a40 and c8167ee.

📒 Files selected for processing (1)
  • src/sdk/accountspace_nb.js (4 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9182
File: src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js:9-17
Timestamp: 2025-08-08T13:12:46.728Z
Learning: In upgrade script src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js for noobaa-core, rely on structural detection (e.g., pool.mongo_info, and resource_type === 'INTERNAL') with name-prefix fallback for removing legacy mongo/internal pools, instead of depending solely on config.INTERNAL_STORAGE_POOL_NAME or config.DEFAULT_POOL_NAME. Handle multi-system stores and remove all matching pools in one change.
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9291
File: src/server/common_services/auth_server.js:548-554
Timestamp: 2025-11-19T15:03:42.260Z
Learning: In src/server/common_services/auth_server.js, account objects are loaded directly from system_store (e.g., system_store.data.get_by_id()), so account.owner is an object ID reference with an ._id property, not a string. This differs from s3_rest.js where account.owner is a string due to RPC serialization.
📚 Learning: 2025-11-19T15:03:42.260Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9291
File: src/server/common_services/auth_server.js:548-554
Timestamp: 2025-11-19T15:03:42.260Z
Learning: In src/server/common_services/auth_server.js, account objects are loaded directly from system_store (e.g., system_store.data.get_by_id()), so account.owner is an object ID reference with an ._id property, not a string. This differs from s3_rest.js where account.owner is a string due to RPC serialization.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-13T07:56:23.620Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9281
File: src/server/system_services/account_server.js:1053-1058
Timestamp: 2025-11-13T07:56:23.620Z
Learning: In noobaa-core, account_server.js is only used in containerized deployments, not in NSFS/NC deployments. NSFS/NC deployments have separate account management code in src/manage_nsfs/ directory. Therefore, account_server.js only processes accounts from account_schema.js where owner is an objectid reference, never from nsfs_account_schema.js where owner is a string.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-12T04:55:42.193Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.

Applied to files:

  • src/sdk/accountspace_nb.js
🧬 Code graph analysis (1)
src/sdk/accountspace_nb.js (2)
src/server/system_services/account_server.js (27)
  • requesting_account (1208-1208)
  • requesting_account (1230-1230)
  • requesting_account (1279-1279)
  • requesting_account (1296-1296)
  • requesting_account (1324-1324)
  • requesting_account (1355-1355)
  • requesting_account (1368-1368)
  • requesting_account (1396-1396)
  • requesting_account (1413-1413)
  • requesting_account (1434-1434)
  • requesting_account (1476-1476)
  • requesting_account (1505-1505)
  • requesting_account (1527-1527)
  • requesting_account (1556-1556)
  • requesting_account (1570-1570)
  • requesting_account (1589-1589)
  • account_email_wrapped (1280-1280)
  • account_email_wrapped (1435-1435)
  • account_email_wrapped (1477-1477)
  • account_email_wrapped (1506-1506)
  • account_util (25-25)
  • account_util (53-53)
  • params (328-328)
  • params (691-691)
  • params (955-955)
  • req (134-134)
  • req (396-396)
src/util/account_util.js (1)
  • req (680-680)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build Noobaa Image
  • GitHub Check: run-jest-unit-tests
🔇 Additional comments (2)
src/sdk/accountspace_nb.js (2)

40-41: Clarify the deployment context scope for this verification.

The concern about default_resource availability across "all deployment contexts" may be misdirected. According to account management architecture, NSFS/NC deployments use separate account code in src/manage_nsfs/, while accountspace_nb.js is part of the containerized SDK layer. Verify that default_resource is present in the containerized account schema that populates requesting_account objects, which is the only context relevant for this file.


56-56: Verify RPC method signatures accept params without explicit requesting_account.

All RPC method calls (get_user, update_user, delete_user, list_users, create_access_key, get_access_key_last_used, update_access_key, delete_access_key, list_access_keys, tag_user, untag_user, list_user_tags, put_user_policy, get_user_policy, delete_user_policy, list_user_policies) now pass only params without an explicit requesting_account parameter.

Ensure that all these RPC methods in account_server.js have been updated to infer requesting_account from the RPC context (req.account) and that the RPC method signatures no longer require an explicit requesting_account parameter.

Also applies to: 60-60, 66-66, 72-72, 81-81, 85-85, 89-89, 94-94, 99-99, 107-107, 111-111, 115-115, 123-123, 127-127, 131-131, 135-135

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/sdk/accountspace_nb.js (1)

18-22: Constructor fields appear unused; consider cleanup in a follow-up.

this.rpc_client, this.internal_rpc_client, and this.stats are no longer used anywhere in AccountSpaceNB now that all calls go through account_sdk.rpc_client. If nothing else in the codebase depends on these properties being present, you could simplify the constructor signature and remove these assignments in a follow-up to reduce noise.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c8167ee and ebf5f67.

📒 Files selected for processing (1)
  • src/sdk/accountspace_nb.js (3 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9182
File: src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js:9-17
Timestamp: 2025-08-08T13:12:46.728Z
Learning: In upgrade script src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js for noobaa-core, rely on structural detection (e.g., pool.mongo_info, and resource_type === 'INTERNAL') with name-prefix fallback for removing legacy mongo/internal pools, instead of depending solely on config.INTERNAL_STORAGE_POOL_NAME or config.DEFAULT_POOL_NAME. Handle multi-system stores and remove all matching pools in one change.
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9291
File: src/server/common_services/auth_server.js:548-554
Timestamp: 2025-11-19T15:03:42.260Z
Learning: In src/server/common_services/auth_server.js, account objects are loaded directly from system_store (e.g., system_store.data.get_by_id()), so account.owner is an object ID reference with an ._id property, not a string. This differs from s3_rest.js where account.owner is a string due to RPC serialization.
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.
📚 Learning: 2025-11-19T15:03:42.260Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9291
File: src/server/common_services/auth_server.js:548-554
Timestamp: 2025-11-19T15:03:42.260Z
Learning: In src/server/common_services/auth_server.js, account objects are loaded directly from system_store (e.g., system_store.data.get_by_id()), so account.owner is an object ID reference with an ._id property, not a string. This differs from s3_rest.js where account.owner is a string due to RPC serialization.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-13T07:56:23.620Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9281
File: src/server/system_services/account_server.js:1053-1058
Timestamp: 2025-11-13T07:56:23.620Z
Learning: In noobaa-core, account_server.js is only used in containerized deployments, not in NSFS/NC deployments. NSFS/NC deployments have separate account management code in src/manage_nsfs/ directory. Therefore, account_server.js only processes accounts from account_schema.js where owner is an objectid reference, never from nsfs_account_schema.js where owner is a string.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-12T04:55:42.193Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-08-08T13:08:38.361Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9182
File: src/server/system_services/bucket_server.js:1324-1327
Timestamp: 2025-08-08T13:08:38.361Z
Learning: In src/server/system_services/bucket_server.js, the update_all_buckets_default_pool(req) handler expects req.rpc_params.pool_name to be a plain string (not a SensitiveString wrapper), so calling .unwrap() is not needed there.

Applied to files:

  • src/sdk/accountspace_nb.js
🧬 Code graph analysis (1)
src/sdk/accountspace_nb.js (2)
src/server/system_services/account_server.js (27)
  • params (328-328)
  • params (691-691)
  • params (955-955)
  • requesting_account (1208-1208)
  • requesting_account (1230-1230)
  • requesting_account (1279-1279)
  • requesting_account (1296-1296)
  • requesting_account (1324-1324)
  • requesting_account (1355-1355)
  • requesting_account (1368-1368)
  • requesting_account (1396-1396)
  • requesting_account (1413-1413)
  • requesting_account (1434-1434)
  • requesting_account (1476-1476)
  • requesting_account (1505-1505)
  • requesting_account (1527-1527)
  • requesting_account (1556-1556)
  • requesting_account (1570-1570)
  • requesting_account (1589-1589)
  • account_email_wrapped (1280-1280)
  • account_email_wrapped (1435-1435)
  • account_email_wrapped (1477-1477)
  • account_email_wrapped (1506-1506)
  • account_util (25-25)
  • account_util (53-53)
  • req (134-134)
  • req (396-396)
src/util/account_util.js (1)
  • req (680-680)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build Noobaa Image
  • GitHub Check: run-jest-unit-tests
🔇 Additional comments (2)
src/sdk/accountspace_nb.js (2)

55-136: RPC delegations via account_sdk.rpc_client.account.* look consistent.

get_user, update_user, delete_user, list_users, and all access-key/tag/policy methods now delegate directly to account_sdk.rpc_client.account.*(params), which keeps signatures simple and removes the extra requesting_account plumbing. This looks consistent across all methods and should preserve behavior as long as the server-side handlers rely on req.account rather than explicit parameters.


28-43: No changes needed. The code correctly uses requesting_account._id without .toString() because in the containerized deployment context (where accountspace_nb operates via account_sdk), the account object is loaded from system_store where owner is an ObjectId reference with an ._id property. The RPC serialization (which converts IDs to strings) occurs during the account_sdk.rpc_client.account.create_user(req) call, not before it. This differs from S3 REST flows where accounts come pre-serialized from RPC, but both patterns are correct for their respective contexts.

@pull-request-size pull-request-size bot added size/M and removed size/L labels Dec 4, 2025
@shirady shirady force-pushed the iam-remove-system-store-calls branch from 88827be to 977d2da Compare December 4, 2025 11:04
@pull-request-size pull-request-size bot added size/L and removed size/M labels Dec 4, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
src/sdk/accountspace_nb.js (2)

78-98: User access key methods: consistent RPC forwarding.

These access key methods now cleanly proxy to account_sdk.rpc_client.account.* with just params, matching the updated pattern from the user methods. This looks consistent and correct; any redundant return await patterns here can be simplified the same way as above if you prefer.


104-114: User tag methods: straightforward delegation.

tag_user, untag_user, and list_user_tags now simply delegate to the account RPC client with no extra context, which is consistent with the rest of this class and the goal of removing system_store lookups. No functional issues spotted.

🧹 Nitpick comments (2)
src/sdk/accountspace_nb.js (2)

28-51: create_user: requesting_account usage and owner/id wiring look correct.

Using account_sdk.requesting_account instead of re‑querying system_store is appropriate here; _id is already a string in this context, so passing requesting_account._id into get_account_email_from_username and into owner is correct without .toString(). The response mapping also looks consistent with the returned iam_account fields.

If you want to tighten this further, you could:

  • Use iam_account.iam_path from the RPC response instead of recomputing params.iam_path || IAM_DEFAULT_PATH, so the returned value always reflects the server’s source of truth.
  • Optionally default iam_path in req itself (e.g., iam_path: params.iam_path || IAM_DEFAULT_PATH) to keep request/response aligned.

Based on learnings, requesting_account._id is already a string in this file.


53-71: User methods: pass‑through RPC calls look correct (minor async nit).

Forwarding params directly to account_sdk.rpc_client.account.* and dropping the extra requesting_account argument aligns with obtaining the caller context from the RPC layer instead of system_store.

The only minor style nit is the redundant await in return await ... — you could simplify to return account_sdk.rpc_client.account.get_user(params); (and similarly for update_user, delete_user, list_users) if you don’t rely on the extra stack frame.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88827be and 977d2da.

📒 Files selected for processing (1)
  • src/sdk/accountspace_nb.js (3 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9330
File: src/sdk/accountspace_nb.js:30-30
Timestamp: 2025-12-04T10:55:08.638Z
Learning: In src/sdk/accountspace_nb.js, account_sdk.requesting_account comes from RPC serialization, so requesting_account._id is already a string (not an ObjectId). This differs from system_store.get_account_by_email() which returns accounts with ObjectId._id references. Therefore, no .toString() conversion is needed when using account_sdk.requesting_account._id in accountspace_nb.js.
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9291
File: src/server/common_services/auth_server.js:548-554
Timestamp: 2025-11-19T15:03:42.260Z
Learning: In src/server/common_services/auth_server.js, account objects are loaded directly from system_store (e.g., system_store.data.get_by_id()), so account.owner is an object ID reference with an ._id property, not a string. This differs from s3_rest.js where account.owner is a string due to RPC serialization.
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.
📚 Learning: 2025-12-04T10:55:08.638Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9330
File: src/sdk/accountspace_nb.js:30-30
Timestamp: 2025-12-04T10:55:08.638Z
Learning: In src/sdk/accountspace_nb.js, account_sdk.requesting_account comes from RPC serialization, so requesting_account._id is already a string (not an ObjectId). This differs from system_store.get_account_by_email() which returns accounts with ObjectId._id references. Therefore, no .toString() conversion is needed when using account_sdk.requesting_account._id in accountspace_nb.js.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-19T15:03:42.260Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9291
File: src/server/common_services/auth_server.js:548-554
Timestamp: 2025-11-19T15:03:42.260Z
Learning: In src/server/common_services/auth_server.js, account objects are loaded directly from system_store (e.g., system_store.data.get_by_id()), so account.owner is an object ID reference with an ._id property, not a string. This differs from s3_rest.js where account.owner is a string due to RPC serialization.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-13T07:56:23.620Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9281
File: src/server/system_services/account_server.js:1053-1058
Timestamp: 2025-11-13T07:56:23.620Z
Learning: In noobaa-core, account_server.js is only used in containerized deployments, not in NSFS/NC deployments. NSFS/NC deployments have separate account management code in src/manage_nsfs/ directory. Therefore, account_server.js only processes accounts from account_schema.js where owner is an objectid reference, never from nsfs_account_schema.js where owner is a string.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-12T04:55:42.193Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-08-08T13:08:38.361Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9182
File: src/server/system_services/bucket_server.js:1324-1327
Timestamp: 2025-08-08T13:08:38.361Z
Learning: In src/server/system_services/bucket_server.js, the update_all_buckets_default_pool(req) handler expects req.rpc_params.pool_name to be a plain string (not a SensitiveString wrapper), so calling .unwrap() is not needed there.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-08-08T13:12:46.728Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9182
File: src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js:9-17
Timestamp: 2025-08-08T13:12:46.728Z
Learning: In upgrade script src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js for noobaa-core, rely on structural detection (e.g., pool.mongo_info, and resource_type === 'INTERNAL') with name-prefix fallback for removing legacy mongo/internal pools, instead of depending solely on config.INTERNAL_STORAGE_POOL_NAME or config.DEFAULT_POOL_NAME. Handle multi-system stores and remove all matching pools in one change.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-18T07:00:17.653Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_bucket_policy_utils.js:357-368
Timestamp: 2025-11-18T07:00:17.653Z
Learning: In NooBaa codebase, account.name is always a SensitiveString instance, so calling account.name.unwrap() is safe without defensive type checks in functions like get_bucket_policy_principal_arn in src/endpoint/s3/s3_bucket_policy_utils.js.

Applied to files:

  • src/sdk/accountspace_nb.js
🧬 Code graph analysis (1)
src/sdk/accountspace_nb.js (2)
src/server/system_services/account_server.js (27)
  • params (328-328)
  • params (691-691)
  • params (955-955)
  • requesting_account (1208-1208)
  • requesting_account (1230-1230)
  • requesting_account (1279-1279)
  • requesting_account (1296-1296)
  • requesting_account (1324-1324)
  • requesting_account (1355-1355)
  • requesting_account (1368-1368)
  • requesting_account (1396-1396)
  • requesting_account (1413-1413)
  • requesting_account (1434-1434)
  • requesting_account (1476-1476)
  • requesting_account (1505-1505)
  • requesting_account (1527-1527)
  • requesting_account (1556-1556)
  • requesting_account (1570-1570)
  • requesting_account (1589-1589)
  • account_email_wrapped (1280-1280)
  • account_email_wrapped (1435-1435)
  • account_email_wrapped (1477-1477)
  • account_email_wrapped (1506-1506)
  • account_util (25-25)
  • account_util (53-53)
  • req (134-134)
  • req (396-396)
src/util/account_util.js (1)
  • req (680-680)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Noobaa Image
  • GitHub Check: run-package-lock-validation
  • GitHub Check: run-jest-unit-tests
🔇 Additional comments (2)
src/sdk/accountspace_nb.js (2)

24-26: Section renames improve clarity.

Renaming the section headers from generic “ACCOUNT” to “USER …”/“USER ACCESS KEY …”/“USER TAGS …”/“POLICY METHODS” better reflects the IAM semantics and is consistent. No issues here.

Also applies to: 74-76, 100-102, 116-118


120-134: User policy methods: delegation pattern matches the rest.

Policy-related methods (put_user_policy, get_user_policy, delete_user_policy, list_user_policies) follow the same simplified delegation approach as the user and access‑key methods. Assuming the RPC signatures were updated to no longer expect a requesting_account argument, this is correct and consistent.

You may want to confirm RPC signatures once across the codebase to ensure no remaining callers still pass requesting_account, but this file’s usage is coherent with the described change.

@shirady shirady force-pushed the iam-remove-system-store-calls branch from 977d2da to ccc5b63 Compare December 7, 2025 06:28
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/sdk/accountspace_nb.js (3)

28-51: create_user: context usage looks correct; consider normalizing iam_path once

Using account_sdk.requesting_account for both email generation and owner is consistent with the RPC-serialized account object; no remaining system_store dependency here. To avoid any divergence between what is sent and what is returned, you could normalize iam_path once and reuse it:

-    async create_user(params, account_sdk) {
-        const requesting_account = account_sdk.requesting_account;
-        const account_email_wrapped = account_util.get_account_email_from_username(params.username, requesting_account._id);
-        const req = {
+    async create_user(params, account_sdk) {
+        const requesting_account = account_sdk.requesting_account;
+        const iam_path = params.iam_path || IAM_DEFAULT_PATH;
+        const account_email_wrapped = account_util.get_account_email_from_username(
+            params.username,
+            requesting_account._id
+        );
+        const req = {
             name: params.username,
             email: account_email_wrapped,
             has_login: false,
             s3_access: true,
             allow_bucket_creation: true,
-            owner: requesting_account._id,
-            iam_path: params.iam_path,
+            owner: requesting_account._id,
+            iam_path,
             roles: ['admin'],
         };
         const iam_account = await account_sdk.rpc_client.account.create_user(req);
         return {
-            iam_path: params.iam_path || IAM_DEFAULT_PATH,
+            iam_path,
             username: params.username,
             user_id: iam_account.id,
             arn: iam_account.arn,
             create_date: iam_account.create_date,
         };

Based on learnings, using requesting_account._id directly (without .toString()) here is correct because it is already a string from RPC serialization.


53-71: User RPC wrappers are correct; redundant await is optional cleanup

These methods now correctly delegate to account_sdk.rpc_client.account.*(params) without passing requesting_account, aligning with the refactor away from system_store. Since they don’t add logic around the call, you can simplify slightly by dropping the redundant await:

-    async get_user(params, account_sdk) {
-        return await account_sdk.rpc_client.account.get_user(params);
-    }
+    async get_user(params, account_sdk) {
+        return account_sdk.rpc_client.account.get_user(params);
+    }

(and similarly for update_user, delete_user, list_users).


78-98: Access-key RPC wrappers match the new API shape; consider DRYing or dropping await

Forwarding params only into account_sdk.rpc_client.account.* is consistent with the updated server-side RPC contracts. As with the user methods, you can optionally:

  • Remove await and just return account_sdk.rpc_client.account.<method>(params);, or
  • Introduce a tiny helper if you want to reduce repetition across these thin wrappers.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 977d2da and ccc5b63.

📒 Files selected for processing (1)
  • src/sdk/accountspace_nb.js (3 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9330
File: src/sdk/accountspace_nb.js:30-30
Timestamp: 2025-12-04T10:55:08.638Z
Learning: In src/sdk/accountspace_nb.js, account_sdk.requesting_account comes from RPC serialization, so requesting_account._id is already a string (not an ObjectId). This differs from system_store.get_account_by_email() which returns accounts with ObjectId._id references. Therefore, no .toString() conversion is needed when using account_sdk.requesting_account._id in accountspace_nb.js.
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.
📚 Learning: 2025-12-04T10:55:08.638Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9330
File: src/sdk/accountspace_nb.js:30-30
Timestamp: 2025-12-04T10:55:08.638Z
Learning: In src/sdk/accountspace_nb.js, account_sdk.requesting_account comes from RPC serialization, so requesting_account._id is already a string (not an ObjectId). This differs from system_store.get_account_by_email() which returns accounts with ObjectId._id references. Therefore, no .toString() conversion is needed when using account_sdk.requesting_account._id in accountspace_nb.js.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-19T15:03:42.260Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9291
File: src/server/common_services/auth_server.js:548-554
Timestamp: 2025-11-19T15:03:42.260Z
Learning: In src/server/common_services/auth_server.js, account objects are loaded directly from system_store (e.g., system_store.data.get_by_id()), so account.owner is an object ID reference with an ._id property, not a string. This differs from s3_rest.js where account.owner is a string due to RPC serialization.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-13T07:56:23.620Z
Learnt from: shirady
Repo: noobaa/noobaa-core PR: 9281
File: src/server/system_services/account_server.js:1053-1058
Timestamp: 2025-11-13T07:56:23.620Z
Learning: In noobaa-core, account_server.js is only used in containerized deployments, not in NSFS/NC deployments. NSFS/NC deployments have separate account management code in src/manage_nsfs/ directory. Therefore, account_server.js only processes accounts from account_schema.js where owner is an objectid reference, never from nsfs_account_schema.js where owner is a string.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-12T04:55:42.193Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_rest.js:258-261
Timestamp: 2025-11-12T04:55:42.193Z
Learning: In the context of S3 REST requests (src/endpoint/s3/s3_rest.js), the account.owner field from req.object_sdk.requesting_account is already a string (account ID) because it comes from RPC serialization where owner._id.toString() is applied in account_server.js. No additional .toString() or ._id extraction is needed when passing account.owner to IAM utility functions.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-08-08T13:08:38.361Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9182
File: src/server/system_services/bucket_server.js:1324-1327
Timestamp: 2025-08-08T13:08:38.361Z
Learning: In src/server/system_services/bucket_server.js, the update_all_buckets_default_pool(req) handler expects req.rpc_params.pool_name to be a plain string (not a SensitiveString wrapper), so calling .unwrap() is not needed there.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-08-08T13:12:46.728Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9182
File: src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js:9-17
Timestamp: 2025-08-08T13:12:46.728Z
Learning: In upgrade script src/upgrade/upgrade_scripts/5.20.0/remove_mongo_pool.js for noobaa-core, rely on structural detection (e.g., pool.mongo_info, and resource_type === 'INTERNAL') with name-prefix fallback for removing legacy mongo/internal pools, instead of depending solely on config.INTERNAL_STORAGE_POOL_NAME or config.DEFAULT_POOL_NAME. Handle multi-system stores and remove all matching pools in one change.

Applied to files:

  • src/sdk/accountspace_nb.js
📚 Learning: 2025-11-18T07:00:17.653Z
Learnt from: naveenpaul1
Repo: noobaa/noobaa-core PR: 9277
File: src/endpoint/s3/s3_bucket_policy_utils.js:357-368
Timestamp: 2025-11-18T07:00:17.653Z
Learning: In NooBaa codebase, account.name is always a SensitiveString instance, so calling account.name.unwrap() is safe without defensive type checks in functions like get_bucket_policy_principal_arn in src/endpoint/s3/s3_bucket_policy_utils.js.

Applied to files:

  • src/sdk/accountspace_nb.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Noobaa Image
  • GitHub Check: run-package-lock-validation
  • GitHub Check: run-jest-unit-tests
🔇 Additional comments (6)
src/sdk/accountspace_nb.js (6)

24-26: User section header rename improves readability

Renaming this block to “USER METHODS” matches the method names and clarifies intent; no functional impact.


74-76: User access-key section header rename is consistent

The “USER ACCESS KEY METHODS” header matches the underlying IAM semantics better than the previous “ACCOUNT” wording.


100-102: User tags section header rename is appropriate

“USER TAGS METHODS” better reflects that these operate on IAM users rather than top-level accounts.


104-114: Tagging RPC wrappers are correctly updated to use account_sdk.rpc_client

tag_user, untag_user, and list_user_tags now cleanly delegate to the account RPC client with just params; that aligns with removing explicit requesting_account propagation.


116-118: Policy section header remains clear and scoped to user policies

The “POLICY METHODS” header is fine here and matches the user-policy-focused methods below it.


120-134: User policy RPC wrappers align with the new contract

put_user_policy, get_user_policy, delete_user_policy, and list_user_policies correctly call account_sdk.rpc_client.account.*(params) without passing requesting_account. This matches the rest of the refactor and keeps the client surface consistent.

Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
@shirady shirady force-pushed the iam-remove-system-store-calls branch from d6808e3 to 4ddc131 Compare December 8, 2025 10:00
@shirady shirady merged commit 4e40ea7 into noobaa:master Dec 8, 2025
18 checks passed
@shirady shirady deleted the iam-remove-system-store-calls branch December 9, 2025 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants