Skip to content

[Bug] 部分消息推送失败 #10

Description

@hu-qi

从 actions 历史执行记录来看,推送失败的还挺多的

Image Image

比如链接: https://github.com/Open-Source-Bazaar/Open-Source-Bazaar.github.io/actions/runs/20751107331/job/59580455271

需按报错实际情况处理,比如:

const event_name = event.event_name || 'push'; // or another sensible default
const handler = eventHandlers[event_name];
if (!handler) throw new Error(`No handler found for event: ${event_name}`);

copliot 解释:

**Problem**:  
The job failed because the script `.github/scripts/transform-message.ts` threw an error:  
`No handler found for event: undefined` at line 242.  
This occurs when the `event.event_name` variable is `undefined`, causing an exception at:

```typescript
const handler = eventHandlers[event_name];
if (!handler) throw new Error(`No handler found for event: ${event_name}`);

View code (ref: b44ea570e76ca924e0a64c5e548532fb7f5306d0)

Root cause:
The event JSON provided to the script does not include event_name, so the handler lookup fails.

Solution:

  1. Update .github/scripts/transform-message.ts to safely fall back when event_name is missing, or add validation at the start:
// Before processing the event
if (!event.event_name) {
  throw new Error('event_name is missing from the event payload');
}

Or, provide a default value:

const event_name = event.event_name || 'push'; // or another sensible default
const handler = eventHandlers[event_name];
if (!handler) throw new Error(`No handler found for event: ${event_name}`);
  1. Check the workflow step that serializes the event (View workflow file (ref: b44ea570e76ca924e0a64c5e548532fb7f5306d0)):
deno run --allow-all .github/scripts/transform-message.ts

Make sure ${{ toJSON(github) }} provides all necessary properties, including event_name. If not, pass event_name explicitly or enrich the event data before serialization.

Summary of changes:

  • Validate event input for essential fields (especially event_name) before further processing in the script.
  • If event_name is expected from the workflow or GitHub context, verify its availability and update the workflow if required.

After these fixes, rerun the workflow to ensure the handler lookup does not fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions