Skip to content

fix(core/federated): guard aggregation module lookup against None#566

Open
g-k-s-03 wants to merge 2 commits into
kubeedge:mainfrom
g-k-s-03:fix/federated-aggregation-none-guard
Open

fix(core/federated): guard aggregation module lookup against None#566
g-k-s-03 wants to merge 2 commits into
kubeedge:mainfrom
g-k-s-03:fix/federated-aggregation-none-guard

Conversation

@g-k-s-03

Copy link
Copy Markdown

Description

FederatedLearning.__init__() unpacks the result of
self.module_instances.get() directly without a None guard. When the
user's algorithm YAML omits the aggregation block, .get() returns
None and Python crashes with:

TypeError: cannot unpack non-iterable NoneType object

This gives no hint about which module is missing or how to fix the YAML.

Fix

Added a None guard that raises a descriptive ValueError pointing the
user to the missing YAML entry before the unpack is attempted.

File Changed

core/testcasecontroller/algorithm/paradigm/federated_learning/federated_learning.py line 78

Testing

The fix is a pure guard — no behavior change on the happy path where
aggregation module is present.

Fixes #565

@kubeedge-bot kubeedge-bot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jun 26, 2026
@kubeedge-bot

Copy link
Copy Markdown
Collaborator

Welcome @g-k-s-03! It looks like this is your first PR to kubeedge/ianvs 🎉

@kubeedge-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: g-k-s-03
To complete the pull request process, please assign moorezheng after the PR has been reviewed.
You can assign the PR to them by writing /assign @moorezheng in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubeedge-bot kubeedge-bot requested review from Poorunga and hsj576 June 26, 2026 06:08
@kubeedge-bot kubeedge-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 26, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a safety check in the FederatedLearning class initialization to ensure that the required aggregation module is present, raising a ValueError if it is missing. The reviewer suggested extending this validation to also check if the aggregator instance itself is None (i.e., _aggregation[1] is None) to prevent a potential AttributeError later in the execution flow.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

self.module_instances.get() returns None when the aggregation block is
missing from the algorithm YAML. Unpacking None immediately crashes with
TypeError: cannot unpack non-iterable NoneType object

Add a None guard that raises a descriptive ValueError pointing the user
to the missing YAML entry before the unpack is attempted.

Issue: 565
Signed-off-by: g-k-s-03 <govindsingh97704@gmail.com>
@g-k-s-03 g-k-s-03 force-pushed the fix/federated-aggregation-none-guard branch from 26bf3f1 to a13def4 Compare June 26, 2026 06:09
@kubeedge-bot kubeedge-bot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jun 26, 2026
Signed-off-by: g-k-s-03 <govindsingh97704@gmail.com>
@g-k-s-03

Copy link
Copy Markdown
Author

/assign @hsj576, @Poorunga, @MooreZheng can you review this when you get time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(core/federated): TypeError crash when aggregation module missing from YAML

2 participants