Skip to content

chore: report result when action fails#10063

Open
kizuna-lek wants to merge 3 commits intomainfrom
support/report-action-failed-result
Open

chore: report result when action fails#10063
kizuna-lek wants to merge 3 commits intomainfrom
support/report-action-failed-result

Conversation

@kizuna-lek
Copy link
Collaborator

@kizuna-lek kizuna-lek requested a review from a team as a code owner February 27, 2026 07:33
@kizuna-lek kizuna-lek added pick-1.0 Auto cherry-pick to release-1.0 when PR merged pick-1.1 Auto cherry-pick to release-1.1 when PR merged labels Feb 27, 2026
@apecloud-bot
Copy link
Collaborator

Auto Cherry-pick Instructions

Usage:
  - /nopick: Not auto cherry-pick when PR merged.
  - /pick: release-x.x [release-x.x]: Auto cherry-pick to the specified branch when PR merged.

Example:
  - /nopick
  - /pick release-1.1

@github-actions github-actions bot added the size/XS Denotes a PR that changes 0-9 lines. label Feb 27, 2026
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.31%. Comparing base (ea54720) to head (ee670af).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/kbagent/service/action_utils.go 55.55% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10063      +/-   ##
==========================================
- Coverage   51.38%   51.31%   -0.07%     
==========================================
  Files         540      540              
  Lines       58973    58985      +12     
==========================================
- Hits        30306    30271      -35     
- Misses      25688    25747      +59     
+ Partials     2979     2967      -12     
Flag Coverage Δ
unittests 51.31% <55.55%> (-0.07%) ⬇️

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.

@apecloud-bot apecloud-bot added the approved PR Approved Test label Feb 28, 2026
return s.encode(nil, err), nil
}
resp, err := s.handleRequest(ctx, req)
result := string(resp)
Copy link
Contributor

Choose a reason for hiding this comment

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

func blockingCallAction(ctx context.Context, action *kbaproto.Action, parameters map[string]string, timeout *int32) ([]byte, error) {
resultChan, err := nonBlockingCallAction(ctx, action, parameters, timeout)
if err != nil {
return nil, err
}
result := <-resultChan
err = result.err
if err != nil {
var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
errMsg := fmt.Sprintf("exit code: %d", exitErr.ExitCode())
if stderrMsg := result.stderr.String(); len(stderrMsg) > 0 {
errMsg += fmt.Sprintf(", stderr: %s", stderrMsg)
}
return nil, errors.Wrapf(kbaproto.ErrFailed, "%s", errMsg)
}
if errMsg := result.stderr.String(); len(errMsg) > 0 {
return nil, errors.Wrapf(err, "%s", errMsg)
}
return nil, err
}
return result.stdout.Bytes(), nil
}

result would be nil if an error occurred? (line 123)

Copy link
Collaborator Author

@kizuna-lek kizuna-lek Feb 28, 2026

Choose a reason for hiding this comment

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

yes, result maybe nil. but string(resp) works because resp has a known type ([]byte)

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, you don't get any useful information because result is nil.

@cjc7373
Copy link
Contributor

cjc7373 commented Feb 28, 2026

Check my previous PR #9454. Do you want the similar thing?

@kizuna-lek
Copy link
Collaborator Author

kizuna-lek commented Feb 28, 2026

Check my previous PR #9454. Do you want the similar thing?

yes, report result would be helpful for debug, especially in scenarios where action execution times out

@github-actions github-actions bot removed the size/XS Denotes a PR that changes 0-9 lines. label Mar 2, 2026
@apecloud-bot apecloud-bot removed the approved PR Approved Test label Mar 2, 2026
@github-actions github-actions bot added the size/S Denotes a PR that changes 10-29 lines. label Mar 2, 2026
@cjc7373
Copy link
Contributor

cjc7373 commented Mar 4, 2026

For now, if an action exits normally:

  • stdout is logged
  • stderr is not logged

If we want to align with API definitions, we should always log stderr and never log stdout? @leon-ape what's your point?

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

Labels

pick-1.0 Auto cherry-pick to release-1.0 when PR merged pick-1.1 Auto cherry-pick to release-1.1 when PR merged size/S Denotes a PR that changes 10-29 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement] Report the execution result of kbagent when the action fails

4 participants