Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

BReg: the facility example's address correction writes the untrimmed postal code

Đang mở Phù hợp với người mới
#2,227 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/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ệ
rust
Lĩnh vực
backend, testing

Hướng nghiên cứu

Đọc products/breg/examples/facility/plans/correct-address.rhai, đặc biệt là phần làm sạch đầu vào và gán hiệu ứng quanh dòng 20. Sau đó, xem crates/registry-bregctl/tests/refactor_cli_contract.rs để biết cách tệp này tạo ví dụ facility và chạy action-test. Thêm một trường hợp có mã bưu chính chứa khoảng trắng ở đầu và cuối, mong đợi "1234"; hoàn tất khi trường hợp đó chạy qua và hiệu ứng lưu giá trị đã bỏ khoảng trắng.

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

Mô tả

area:breg bug

The facility example's address correction Action trims the postal code, checks it, and then
writes the original input. products/breg/examples/facility/plans/correct-address.rhai reads
the input on line 2, calls postal_code.trim() on line 3 (Rhai's trim changes the string in
place and returns nothing), refuses an empty value on line 4, and then on line 20 sets the field
from ctx.inputs["postal-code"] instead of postal_code. A padded value passes the check and is
stored with its spaces. Readers copy this example as the pattern for input cleanup, so it
teaches the bug.

Minimal repro, with a copy of products/breg/examples/facility in facility/:

cat > in.json <<'E'
{"facility":"00000000-0000-4000-8000-000000000001","address-line":"2 Market Street","city":"Example city","postal-code":" 1234 "}
E
cat > trimmed.json <<'E'
{"effects":[{"id":"facility-address","set":{"address-line":"2 Market Street","city":"Example city","postal-code":"1234"}}]}
E
bregctl --format json project action-test --action correct-address --input in.json --expect trimmed.json facility

The run fails with action-test.expect.mismatch at expect/effects/0/set/postal-code. The same
run passes when the expectation's postal-code is " 1234 ".

Expected: the effect sets postal-code to "1234".

Likely fix: on line 20 of correct-address.rhai, write "postal-code": postal_code. The docs
page docs/site/src/content/docs/configure/breg-actions.mdx excerpts only lines 1 to 11 of this
script (its test-excerpt), so the excerpt gate is unaffected.

Tests: the example has no action-test case today. crates/registry-bregctl/tests/refactor_cli_contract.rs
already builds a project from products/breg/examples/facility; an action-test run there with
a padded postal code and an --expect of "1234" would pin the behavior. The example's own
examples/inputs/correction.json uses an unpadded postal code, so it does not catch this.

Ngôn ngữ chính
Rust
Star
2
Fork
0
Merge trung bình
9 giờ 24 phút
Pull request đã merge (30 ngày)
271

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

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 registrystack/registry-stack

Tất cả issue của registrystack/registry-stack

Issue tương tự

Thêm issue về Rust

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.