Pin exact diagnostic message assertions for invalid requirement IDs and basenames in specvalidation tests
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
- 82/100
Hướng nghiên cứu
Trước tiên, hãy đọc mẫu wantMessages hiện có trong validator/internal/specvalidation/schema_test.go để nắm quy ước, sau đó mở identifiers_test.go (TestValidateRequirementIDs) và basenames_test.go (TestValidateRequirementBasename). Thêm các khẳng định thông điệp chính xác cho các trường hợp không hợp lệ REQ-CORE--00001, REQ---00001 và notes.yaml, dùng các chuỗi được trích trong issue, lấy từ identifiers.go:34 và basenames.go:38. Xác nhận bằng go test ./validator/internal/specvalidation/..., sau đó sửa một thông điệp trong các tệp mã nguồn để kiểm tra xem test có thực sự thất bại kèm diff hay không.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happened
In PR #593 (commit d5fb98fbad98de7d3bf5fef397c55c9c937d2965), diagnostic messages in validator/internal/specvalidation/identifiers.go:34 and validator/internal/specvalidation/basenames.go:38 were updated to specify "hyphen-separated alphanumeric segments":
"Requirement ID %q is invalid. Use REQ-<SCOPE>-<NNNNN> with an uppercase scope of hyphen-separated alphanumeric segments and a five-digit sequence."
"Requirement file basename %q is invalid. Use REQ-<SCOPE>-<NNNNN>.yaml with an uppercase scope of hyphen-separated alphanumeric segments and a five-digit sequence."
However, in validator/internal/specvalidation/identifiers_test.go (TestValidateRequirementIDs), test assertions only verify diag.Code == CodeInvalidID, diag.Field == "id", and substring identifiesID(diag.Message, tc.wantIDs[i]) (which only checks that the ID string appears in the message). In validator/internal/specvalidation/basenames_test.go (TestValidateRequirementBasename), assertions only check for substring containment of "notes" and "REQ-<SCOPE>-<NNNNN>.yaml". Neither suite asserts the full diagnostic message or the newly added guidance "hyphen-separated alphanumeric segments".
Maintainer @JohnStrunk noted in PR #593 review (https://github.com/redhat-et/ProtoBot/pull/593#pullrequestreview-3504313264):
"3. No test pins the new message text. A search for hyphen-separated finds only the two source lines. Optional: add the exact-message test from the triage proposal."
During triage of Issue #501, the triage agent (fullsend-ai-triage) had proposed a dedicated test function (TestRequirementIDDiagnosticMessage) asserting the exact updated diagnostic text, but it was not included in PR #593 because Issue #501 did not make it a mandatory criterion.
What could go better
In validator/internal/specvalidation/schema_test.go, previous issues #539, #575, and #576 systematically replaced partial substring matching with exact wantMessages assertions across all error cases to prevent diagnostic wording regressions and ensure user-facing guidance remains stable.
Leaving identifiers_test.go and basenames_test.go with only code and substring checks leaves the newly clarified diagnostic wording unpinned. If a future edit or refactor inadvertently alters the message format or removes the hyphen-separated segment explanation, no test in the test suite will fail. Adding exact message pinning aligns identifiers_test.go and basenames_test.go with the testing conventions established in schema_test.go.
Proposed change
- In
validator/internal/specvalidation/identifiers_test.go:- Add a unit test function
TestRequirementIDDiagnosticMessage(t *testing.T)(matching the test proposed by the triage agent on #501) or add exact message assertions toTestValidateRequirementIDsverifying that invalid requirement IDs (such asREQ-CORE--00001andREQ---00001) produce the exact expected message:
Requirement ID "REQ-CORE--00001" is invalid. Use REQ-<SCOPE>-<NNNNN> with an uppercase scope of hyphen-separated alphanumeric segments and a five-digit sequence.
- Add a unit test function
- In
validator/internal/specvalidation/basenames_test.go:- Update
TestValidateRequirementBasenamefor the malformed requirement basename test case to assert the exact diagnostic message:
Requirement file basename "notes.yaml" is invalid. Use REQ-<SCOPE>-<NNNNN>.yaml with an uppercase scope of hyphen-separated alphanumeric segments and a five-digit sequence.
- Update
Validation criteria
go test ./validator/internal/specvalidation/...verifies exact diagnostic message strings for bothCodeInvalidIDandCodeRequirementInvalidBasename.- Altering the diagnostic message string in
identifiers.goorbasenames.gocausesgo testto fail with a mismatch diff. - All pre-commit hooks (
python scripts/lint.py --all-files) and Go foundation checks pass cleanly.
Related issues checked
Searched: pin diagnostic message identifiers basenames; wantMessages identifiers_test CodeInvalidID; diagnostic message assertions test; CodeRequirementInvalidBasename identifiers_test basenames_test
Considered: #501, fullsend-ai/agents#2067, fullsend-ai/agents#2097, fullsend-ai/agents#2065, #511, #499, #539, #519, #531, #576, #479, #575, #456, #465, #506
- #501: Closed; updated diagnostic strings in PR #593 but omitted adding exact message test assertions.
- fullsend-ai/agents#2067: Open; review correctness check for assertion weakening in PR diffs; does not add tests to ProtoBot.
- fullsend-ai/agents#2097: Open; code agent prompt guidance for updating pre-existing table tests; does not modify ProtoBot tests.
- fullsend-ai/agents#2065: Open; style conventions check for diagnostic field paths; does not add test assertions.
- #511, #519, #531, #539, #575, #576: Closed; hardened and enforced exact diagnostic message assertions (wantMessages) specifically within schema_test.go, leaving identifiers_test.go and basenames_test.go unpinned.
- #499, #479: Closed; hardened cycle diagnostic assertions in relationships_test.go.
- #456, #465, #506: Closed; addressed test tag scanning, schema blank validation, and os.DevNull linting; unrelated to identifier message tests.
Generated by retro agent from https://github.com/redhat-et/ProtoBot/pull/593
- Ngôn ngữ chính
- Go
- Star
- 7
- Fork
- 9
- Merge trung bình
- 22 giờ 37 phút
- Pull request đã merge (30 ngày)
- 118
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của redhat-et/ProtoBot
-
documentation triaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
redhat-et/ProtoBot#589 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation risk/low triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
redhat-et/ProtoBot#588 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
feature infra needs-human risk/low triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
redhat-et/ProtoBot#579 · 6 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
blocked documentation infra risk/low triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
redhat-et/ProtoBot#552 · 6 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug infra triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
redhat-et/ProtoBot#543 · 4 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của redhat-et/ProtoBot
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
sresarehumantoo/cc-artex#456 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ollama/ollama#20021 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
factory:subtask
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
release
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
github/gh-aw-mcpg#17603 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
avr: SPI Mode2 runs as mode 1Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
tinygo-org/tinygo#6727 ·
Maintainer thường phản hồi trong vòng 1 ngày