Skip to content

fix: resolve NPE when using built-in API key#164

Open
LegGasai wants to merge 1 commit intoopenkruise:masterfrom
LegGasai:fix_api_key
Open

fix: resolve NPE when using built-in API key#164
LegGasai wants to merge 1 commit intoopenkruise:masterfrom
LegGasai:fix_api_key

Conversation

@LegGasai
Copy link
Copy Markdown

@LegGasai LegGasai commented Feb 27, 2026

Ⅰ. Describe what this PR does

This PR fixes a NullPointerException that occurs when calling the ListByOwner API to list API keys for a given owner.

The issue happens when returning a list of API keys that includes the system built-in admin API key (e.g., some-api-key created during deployment). The built-in key has its CreatedByfield set to null:

{
  "createdAt": "2026-02-12T12:37:10.131568431Z",
  "id": "xxxxxx",
  "key": "some-api-key",
  "name": "admin",
  "createdBy": null
}

In the code: pkg/servers/e2b/keys/keys.go#236

if apikey.ID == owner || apikey.CreatedBy.ID == owner { ... }

the apikey.CreatedBy.ID dereference causes a panic when CreatedBy is nil.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how to verify it

Ⅳ. Special notes for reviews

@kruise-bot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

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

@kruise-bot
Copy link
Copy Markdown

Welcome @LegGasai! It looks like this is your first PR to openkruise/agents 🎉

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.42%. Comparing base (b6f460e) to head (fb51a25).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #164      +/-   ##
==========================================
- Coverage   55.50%   55.42%   -0.08%     
==========================================
  Files          94       94              
  Lines        5378     5378              
==========================================
- Hits         2985     2981       -4     
- Misses       2169     2173       +4     
  Partials      224      224              
Flag Coverage Δ
unittests 55.42% <100.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LegGasai
Copy link
Copy Markdown
Author

cc @furykerry Could you please review this PR?

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.

3 participants