`cre workflow build` ignores --target and compiles a random target's workflow-path

Đang mở
#631 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
cli

Hướng nghiên cứu

Start with internal/settings/workflow_settings.go and trace how cre workflow build obtains its workflow path versus how hash and deploy resolve the selected target. Use the two-target YAML example in the issue to reproduce the mismatch; done means build --target creator-settings consistently builds create-workflow.ts or rejects --target with documented behavior.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

What happens

cre workflow build ignores --target. When workflow.yaml has more than one target with different workflow-paths, the command compiles a randomly chosen target's workflow, and the choice can change from one run to the next.

cre workflow hash --target and cre workflow deploy --target are not affected: they compile the target's own workflow-path every time.

Why

build gets its source path from settings.GetWorkflowPathFromFile, which calls workflowPathFromRaw (internal/settings/workflow_settings.go). That function ranges over the parsed YAML map and returns the first workflow-path it finds. Go map iteration order is randomised, and the --target value is never consulted.

Reproduce

A workflow.yaml with two targets:

resolver-settings:
  user-workflow:
    workflow-name: "resolver"
  workflow-artifacts:
    workflow-path: "./workflow.ts"
    config-path: "./config.json"

creator-settings:
  user-workflow:
    workflow-name: "creator"
  workflow-artifacts:
    workflow-path: "./create-workflow.ts"
    config-path: "./config.json"
for i in 1 2 3 4 5 6; do
  cre workflow build . --target creator-settings -o out.wasm >/dev/null && wc -c < out.wasm
done

Expected: six identical sizes, the build of create-workflow.ts.
Actual: the size alternates between the two workflows. With our two-entry project, six runs gave 6038515 (workflow.ts) twice and 5944943 (create-workflow.ts) four times, on both v1.31.0 and v1.39.0 (darwin/arm64).

Impact

We used cre workflow build --target to compute an expected workflow ID before deploying, to skip re-deploying shards that hadn't changed. Because the wrong workflow was sometimes compiled, the check produced false "changed" results and we deleted and re-registered unchanged workflows. We have switched to cre workflow hash --target, which compiles the right file.

Suggested fix

Have build resolve workflow-path from the --target settings, as hash and deploy do. Alternatively, reject --target on build and document that it uses the folder's single workflow. At minimum, iterate keys in a deterministic order so the result is stable.

Ngôn ngữ chính
Go
Star
25
Fork
31
Merge trung bình
3 ngày 6 giờ
Pull request đã merge (30 ngày)
7

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của smartcontractkit/cre-cli

Tất cả issue của smartcontractkit/cre-cli

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.