Report a malformed required-extension name at its own array position, and cover it
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
Research direction
Start in schema_diagnostic in tests/test_repository.py around line 320, where the propertyNames branch appends the offending string to the instance path. Print error.absolute_schema_path for an extensions key and for a metadata.requiredExtensions item, then append only for propertyNames. Add the two structural fixtures under conformance/structural/ and their cases, then run the unittest discover command. Done means both new cases report /metadata/requiredExtensions/0 with one diagnostic each. Pull request #143 is already open against this issue, so check it first.
Written by the indexing model from the issue text.
Description
Goal
Make the repository's validator point a malformed metadata.requiredExtensions name at the array element (/metadata/requiredExtensions/0), and add two structural cases for it: an unqualified name and a reserved org.judgmentpack. name.
Why
Core §9 gives extension names reverse-domain form, and reserves the org.judgmentpack. prefix. The schema holds metadata.requiredExtensions items to the same pattern as the keys of extensions (schema/judgment-pack-core.schema.json:417). The corpus covers the pattern only for extensions keys (structural-unqualified-extension, structural-reserved-extension-name). Removing the pattern from the items of requiredExtensions on current main (a024118), with the full suite of 100 tests, passes. No fixture has an unqualified or reserved name in requiredExtensions.
The validator also gives such a name a pointer that names nothing. This branch (tests/test_repository.py:320):
elif "org\\.judgmentpack" in pattern:
code = "JPS-STRUCTURE-EXTENSION-NAME"
if isinstance(error.instance, str):
instance_path.append(error.instance)
appends the offending string to the error's path. That is right for an extensions key, which the schema checks through propertyNames, so the path ends at the object and the key must be added. It is wrong for an array item, whose path already ends at the item. Measured on a024118 with "requiredExtensions": ["review-policy"], the validator reports JPS-STRUCTURE-EXTENSION-NAME at /metadata/requiredExtensions/0/review-policy, which resolves to nothing. jpack spec validate --format json (jpack 0.24.0) reports /metadata/requiredExtensions/0 for the same document, one diagnostic.
Both cases were prototyped from valid/minimal-expense-approval.json with "metadata": {"requiredExtensions": ["review-policy"]} and ["org.judgmentpack.review-policy"]. On the unmodified validator both fail on the pointer. With the branch changed to append only when "propertyNames" in schema_path, both pass with one diagnostic each, the existing two extensions cases still pass, and removing the pattern from the items fails exactly the two new cases.
Scope
- In
schema_diagnostic, append the offending string only for apropertyNameserror. To see what tells the two apart, printerror.absolute_schema_pathfor anextensionskey and for arequiredExtensionsitem. - Add two fixtures under
conformance/structural/and two entries beside the existing extension-name cases, withlayer: "structural",expectedResult: "invalid",JPS-STRUCTURE-EXTENSION-NAMEat/metadata/requiredExtensions/0, andspecSection: "§9". - Update the corpus count statements; a harness test names each stale one.
- Do not change the schema, the spec, any other code mapping, or any existing fixture or case.
Acceptance criteria
- The two new cases pass, and
structural-unqualified-extensionandstructural-reserved-extension-namestill pass unchanged. - Each new fixture carries only its one defect.
- Try the mutation and say so: (1) restore the old branch and watch both new cases fail on the pointer; (2) remove the
patternfrom therequiredExtensionsitems and watch both gradevalid. Say in the pull request that you did both. - The corpus count statements match the manifest again.
-
python -m pip install -r requirements-dev.txtthenpython -m unittest discover -s tests -vpasses. - Every commit includes a DCO sign-off created with
git commit -s.
Contributor learning
A JSON Schema error's path says where the failing value sits. For propertyNames the failing value is a key, which has no place of its own in the instance path. For an array item it does. You will see why "record what the suite reports" is only as good as the pointer the validator builds.
- Dominant language
- Python
- Stars
- 5
- Forks
- 6
- Avg merge
- 6h 15m
- Merged PRs (30d)
- 69
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Judgment-Pack/judgment-pack-spec
-
RFC 0018 §9.3: the dependencies row still says absent for a local filePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 Under an hour Newbie friendliness 72/100
Judgment-Pack/judgment-pack-spec#200 ·
Maintainers usually reply within 1 day
-
Cover a rule's or an exception's reference list written without its array, or with a repeated entryOpengood first issue
Difficulty 2/5 Half a day Newbie friendliness 76/100
Judgment-Pack/judgment-pack-spec#158 ·
Maintainers usually reply within 1 day
-
RFC 0018: define portable page bindings for multiple discovered endpointsPossibly taken @kikashy claimed this today. Open
Judgment-Pack/judgment-pack-spec#199 · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 22/100
Judgment-Pack/judgment-pack-spec#174 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 8/100
Judgment-Pack/judgment-pack-spec#172 · 3 comments ·
Maintainers usually reply within 1 day
All issues in Judgment-Pack/judgment-pack-spec
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ok-oldking/ok-wuthering-waves#1785 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
healthchecks/healthchecks#1349 ·
-
deployment release-lag
Difficulty 1/5 Under an hour Newbie friendliness 68/100
nolte/kamerplanter#2374 ·
Maintainers usually reply within 1 day
-
bug v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
modelcontextprotocol/python-sdk#3725 ·
Maintainers usually reply within 1 day
-
batchterms() drops queries without a similar() clause, misaligning results with inputsPossibly taken @MohammadHijjawi97 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day