Skip to content

Sync example plugin zoraxy_plugin copies after AccessRuleCreatedEvent update#1114

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-check-example-plugins-job
Draft

Sync example plugin zoraxy_plugin copies after AccessRuleCreatedEvent update#1114
Copilot wants to merge 3 commits intomainfrom
copilot/fix-check-example-plugins-job

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 11, 2026

check-example-plugins CI was failing because build_all.sh copies src/mod/plugins/zoraxy_plugin into each example plugin, and the source had gained a new field (TrustProxyHeadersOnly) that wasn't reflected in the committed copies — causing git diff --exit-code to fail on every run.

Changes

  • Synced events/events.go in all 10 example plugins to match the current source, adding the missing TrustProxyHeadersOnly bool field to AccessRuleCreatedEvent:
type AccessRuleCreatedEvent struct {
    ID                    string `json:"id"`
    Name                  string `json:"name"`
    Desc                  string `json:"desc"`
    BlacklistEnabled      bool   `json:"blacklist_enabled"`
    WhitelistEnabled      bool   `json:"whitelist_enabled"`
    TrustProxyHeadersOnly bool   `json:"trust_proxy_headers_only"` // added
}

Affected plugins: api-call-example, debugger, dynamic-capture-example, event-subscriber-example, helloworld, plugin2plugin-comms-peer1, plugin2plugin-comms-peer2, restful-example, static-capture-example, upnp.

Original prompt

Create a fix for failing GitHub Actions job check-example-plugins in repo tobychui/zoraxy (workflow: .github/workflows/ci.yaml).

Failure details:

  • Workflow step runs in example/plugins: bash build_all.sh && git diff --exit-code.
  • Job logs show the step exits with code 1 after printing an error context snippet around a Go struct field:
    • TrustProxyHeadersOnly bool json:"trust_proxy_headers_only"``
    • and a method func (e *AccessRuleCreatedEvent) GetName() EventName {
  • This likely indicates build_all.sh either fails to build or generates/rewrites tracked files causing git diff --exit-code to fail.

Task:

  1. Investigate example/plugins/build_all.sh and any scripts/generators it runs.
  2. Reproduce the failure in CI context and identify the exact cause:
    • If compile error: fix the code so build_all.sh succeeds.
    • If generated file diffs: make generation deterministic and/or commit the generated outputs that should be tracked.
  3. Update relevant files so that running bash build_all.sh in example/plugins leaves the repo clean (git diff --exit-code passes) and builds succeed.
  4. Ensure Go formatting and any generator outputs are stable across environments.
  5. Add/adjust documentation or CI hints only if necessary.

Constraints:

  • Keep the intent of the CI check: example plugins should be up-to-date and build cleanly.
  • Prefer deterministic generation over weakening the CI check.

Expected result:

  • After changes, GitHub Actions workflow CI (lints, tests (todo), and builds) passes, especially check-example-plugins.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failing job is check-example-plugins, specifically this step in .github/workflows/ci.yaml:

  • example/plugins: bash build_all.sh && git diff --exit-code

This job fails when either:

  1. build_all.sh returns a non-zero exit code (build failure), or
  2. build_all.sh modifies tracked files (so git diff --exit-code detects changes), meaning generated outputs aren’t committed / builds aren’t reproducible.

What the log indicates

Your log shows a --- ERROR --- block printing a snippet of Go source around:

TrustProxyHeadersOnly bool   `json:"trust_proxy_headers_only"`
}

func (e *AccessRuleCreatedEvent) GetName() EventName {

…and then the step exits with code 1. This pattern strongly suggests build_all.sh runs a formatter or code generator that changes Go files, and then treats the diff as an error (or the script itself detects a diff and prints context before exiting).

Fix (most likely): commit the generated/normalized files

  1. Run the same command locally from the same directory CI uses:
cd example/plugins
bash build_all.sh
git status
git diff
  1. If you see changes, commit them in the PR. CI is explicitly enforcing “example plugins are up to date”.

Typical causes:

  • go fmt (or goimports) reformatting code
  • generated code (events/config structs, plugin metadata, etc.) being regenerated with new fields like trust_proxy_headers_only
  • plugin introspection/manifest outputs being updated

Make the output deterministic (if changes keep appearing)

If every CI run produces diffs even after committing, then the build script is likely generating non-deterministic output (timestamps, Go version strings, absolute paths, map iteration order, etc.).

Common hardening steps inside example/plugins/build_all.sh:

  • Ensure any generator is called with stable inputs (no timestamps)
  • Avoid embedding build time / host info
  • If using go generate, ensure the generator code produces stable ordering (sort keys before emitting JSON/YAML)
  • Ensure gofmt is run consistently (and locally in the same way CI runs it)

If instead it’s a real compile error

The truncated log doesn’t show the actual compiler error text, but the failure happens during bash build_all.sh. Run the same script locally to surface the full error and fix the compilation issue it reports (the snippet suggests it’s in an “event” type file near AccessRuleCreatedEvent).

Concrete next change to make in the PR

  • Run bash build_all.sh under example/plugins/
  • Commit any resulting diffs (this is what git diff --exit-code is enforcing)
  • Push and re-run CI

If you paste the contents of example/plugins/build_all.sh (or the full --- ERROR --- section from the job log), I can point to the exact file(s) that changed and suggest a precise patch (e.g., sorting output keys, removing timestamps, or fixing a specific compile error).

User: Can you create a pull request to fix it for me?

Assistant: I’ve kicked off the pull request creation process to apply a fix, but it’s currently waiting on t...

This pull request was created from Copilot chat.

Copilot AI and others added 2 commits April 11, 2026 13:19
…adersOnly field)

Agent-Logs-Url: https://github.com/tobychui/zoraxy/sessions/13328b84-2bb2-4e23-85f0-274ea2e5a64b

Co-authored-by: tobychui <24617523+tobychui@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions job check-example-plugins Sync example plugin zoraxy_plugin copies after AccessRuleCreatedEvent update Apr 11, 2026
Copilot AI requested a review from tobychui April 11, 2026 13:22
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