Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

CI failing with 7 test failures in plugin-security. Hook registration was missing kernel.use fallback, causing test mocks to fail.

Changes

Added kernel.use fallback to match the pattern in plugin-multitenancy:

const registerHook = (name: string, handler: any) => {
    if (typeof ctx.hook === 'function') {
        ctx.hook(name, handler);
    } else if (typeof (kernel as any).use === 'function') {
        (kernel as any).use(name, handler);  // ← Added
    } else if (typeof (kernel as any).hooks?.register === 'function') {
       (kernel as any).hooks.register(name, handler);
    } else {
       this.logger.warn(`Cannot register hook '${name}': no hook registration mechanism available`);
    }
};

This provides compatibility with test mocks and legacy kernel implementations that use the simpler kernel.use() API.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fastdl.mongodb.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/objectql/objectql/node_modules/.bin/../vitest/vitest.mjs run (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/objectql/objectql/node_modules/.bin/../vitest/vitest.mjs run --reporter=verbose conf�� get --global s pull.rebase (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

引用: https://github.com/objectstack-ai/objectql/actions/runs/21851493748/job/63060617183#step:10:1

fix all build and test errors


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Feb 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectql Ready Ready Preview, Comment Feb 10, 2026 4:59am

Request Review

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix all build and test errors Add kernel.use fallback to plugin-security hook registration Feb 10, 2026
Copilot AI requested a review from hotlong February 10, 2026 04:57
@hotlong hotlong marked this pull request as ready for review February 10, 2026 05:23
Copilot AI review requested due to automatic review settings February 10, 2026 05:23
@hotlong hotlong merged commit ef4d639 into copilot/upgrade-to-latest-version Feb 10, 2026
4 checks passed
@hotlong hotlong deleted the copilot/fix-build-and-test-errors branch February 10, 2026 05:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes plugin-security hook registration compatibility by adding a kernel.use() fallback when ctx.hook() is not available, aligning behavior with the established pattern used by other plugins (e.g. multi-tenancy) and unblocking test mocks.

Changes:

  • Added kernel.use(name, handler) fallback in registerSecurityHooks() when ctx.hook is not provided.
  • Kept existing fallback to kernel.hooks.register(...) and warning when no hook registration mechanism exists.

} else if (typeof (kernel as any).use === 'function') {
(kernel as any).use(name, handler);
} else if (typeof (kernel as any).hooks?.register === 'function') {
(kernel as any).hooks.register(name, handler);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

kernel.hooks.register is invoked with only (name, handler), but in this repo the hook manager registration API is typically (event, objectName, handler, packageName?) (e.g. ObjectQL.on() delegates to kernel.hooks.register(event, objectName, handler, packageName)). If this branch is hit, hooks may be registered with the wrong arguments. Consider passing a wildcard object name (e.g. '*') and/or branching on kernel.hooks.register.length to support both 2-arg and 3+/4-arg signatures safely.

Suggested change
(kernel as any).hooks.register(name, handler);
const hooks = (kernel as any).hooks;
// Support both 2-arg and 3+/4-arg hook registration APIs.
// Typical kernel.hooks.register signature in this repo: (event, objectName, handler, packageName?)
if (typeof hooks.register === 'function' && hooks.register.length >= 3) {
// Use wildcard objectName so security hooks apply to all objects.
hooks.register(name, '*', handler);
} else {
// Fallback for runtimes that only support (name, handler).
hooks.register(name, handler);
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants