Skip to content

feat(query): port IsError/ErrorReason from kuribara-hideaki fork#363

Open
berezovskyi wants to merge 13 commits into
mainfrom
integrate-fork-kuribara
Open

feat(query): port IsError/ErrorReason from kuribara-hideaki fork#363
berezovskyi wants to merge 13 commits into
mainfrom
integrate-fork-kuribara

Conversation

@berezovskyi
Copy link
Copy Markdown
Member

@berezovskyi berezovskyi commented Jun 19, 2025

Summary

Integrate the OSLC Query enhancements from kuribara-hideaki/oslc4net.

What's ported

  • db49995IsError / ErrorReason as properties on clauses
  • efcacd76 — orderBy parse-error tolerance
  • 127e068awhere … in [… (unclosed list) tolerance

Code changes:

  • New IBaseClause interface with IsError (bool) and ErrorReason (string?). WhereClause and SortTerms (and therefore OrderByClause) now extend it.
  • WhereClauseImpl and SortTermsImpl gain error-state constructors.
  • QueryUtils.ParseWhere / ParseOrderBy catch RecognitionException and recursively walk the parse tree for CommonErrorNodes, returning an error-state clause instead of throwing. The recursive walk is what catches deep failures like qm:state in ["Open" or qm:testcase=.

❗️ Breaking change

QueryUtils.ParseWhere and QueryUtils.ParseOrderBy no longer throw ParseException on invalid input. Callers must inspect clause.IsError (and optionally ErrorReason) instead. Audit performed (see comment); only one prod method per parser is affected; only the in-tree parameterized tests needed updates. The other 4 parsers (ParsePrefixes, ParseSelect, parseProperties, ParseSearchTerms) still throw — out of scope for this PR.

What's NOT ported (and why)

Fork change Status Reason
834cdddSortTerms.ChildrenIList<ITree> ❌ regression Fork threw away SimpleSortTermImpl/ScopedSortTermImpl resolution; ours is more complete.
31d2858 — bare * as where-clause value (e.g. qm:title=*) ❌ deferred Not in the OSLC Query v3.0 spec (wildcards are LHS-only); eclipse-lyo doesn't ship it either; would require a parser regen blocked by an unmaintained ANTLR 3 CSharp3 toolchain. Use quoted qm:title="*" instead — that works today. See OslcWhere.g header comment and Impl/GeneratingParsers.txt for the regen blocker write-up.

This concludes my attempt to analyze the `kuribara-hideaki/oslc4net` fork and integrate its changes.

Due to significant divergence and some limitations I encountered that prevented complex manual code merging, I wasn't able to complete the full integration of the fork's code enhancements.

However, as you requested, I have included the following:
1.  An updated `.gitignore` file based on the fork's improvements.
2.  Conceptual (placeholder) integration of some smaller fixes.
3.  A new suite of unit tests added to `OSLC4Net.Core.QueryTests.QueryBasicTest.cs`. These tests are designed to verify the functionality of key enhancements identified in the fork, such as:
    - Improved error handling in query parsing (`IsError`/`ErrorReason` properties).
    - Correct parsing of `*` as an operand in queries.
    - Changes to `SortTerms` structure.

These newly added tests are expected to FAIL, as the underlying code logic from the fork has not been fully implemented in this branch. They serve as a specification and starting point for you to manually port the desired features from the fork.

The `integrate-fork-kuribara` branch contains all changes I made during this process.
@coderabbitai

This comment was marked as outdated.

@berezovskyi
Copy link
Copy Markdown
Member Author

also relevant: eclipse-lyo/lyo#43

berezovskyi and others added 10 commits July 6, 2025 21:50
# Conflicts:
#	OSLC4Net_SDK/Tests/OSLC4Net.Core.QueryTests/QueryBasicTest.cs
Ports the error-as-property pattern from kuribara-hideaki/oslc4net so
that ParseWhere and ParseOrderBy report parse failures via IsError /
ErrorReason on the returned clause instead of throwing ParseException.
This matches the behaviour the failing-test commit (347e5ab) was
written against and makes the 5 placeholder tests pass without
regenerating the ANTLR parsers.

Source commits in the fork:
  db49995 — IsError/ErrorReason on clauses (the IBaseClause interface)
  efcacd7 — orderBy parse-error tolerance
  127e068 — where 'in' parse-error tolerance

Changes:
- New IBaseClause interface with IsError + ErrorReason.
- WhereClause and SortTerms (OrderByClause's base) extend it.
- WhereClauseImpl and SortTermsImpl gain an error-only constructor and
  implement IsError/ErrorReason.
- QueryUtils.ParseWhere / ParseOrderBy now catch RecognitionException
  and recursively scan the parse tree for CommonErrorNodes, returning
  an error-state impl in either case (no more throws on invalid input).
- Existing BasicWhereTest / BasicOrderByTest parametrized cases now
  assert against IsError instead of catching ParseException.
- The two placeholder tests with grammar-incompatible expressions
  (whitespace around `=`, unprefixed orderBy term) use grammar-valid
  expressions that preserve the test intent (quoted asterisk operand,
  Children property access).

Not ported: SortTerms.Children -> IList<ITree> (fork regression that
threw away SimpleSortTermImpl/ScopedSortTermImpl resolution); bare
asterisk as where-clause value (requires grammar regeneration).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@codecov

This comment was marked as outdated.

Documentation-only follow-up to the IsError port (commit d14d4ae):

- CHANGELOG.md gets two entries: an Added line for IBaseClause /
  IsError / ErrorReason, and a Changed (breaking) line noting that
  ParseWhere / ParseOrderBy no longer throw on invalid input.
- OslcWhere.g gains a conformance-notes block citing the OSLC Query
  v3.0 spec (open-projects), calling out the wildcard rule (allowed
  in property names only, not as a value), the bake-in whitespace
  around `and`/`in`, and the dead ANTLR3 CSharp3 toolchain.
- GeneratingParsers.txt rewritten to capture the current state: the
  CSharp3 target crashes StringTemplate on every Java/ST4 combo we
  tested (zulu 8 through temurin 21), so .g edits do not propagate
  without an ANTLR 4 migration or hand-patching. eclipse-lyo's
  identical grammar regenerates fine because they target Java.

No code changes; bare-asterisk-as-value (kuribara-hideaki fork) is
documented as not-ported (it's a non-spec extension and eclipse-lyo
doesn't ship it either).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@berezovskyi berezovskyi changed the title test: new failing tests for OSLC Query support feat(query): port IsError/ErrorReason from kuribara-hideaki fork May 17, 2026
Per the policy in AGENTS.md (added in #754), every file touched
substantively in this PR gets the standard attribution line.

- IBaseClause.cs (new): sole attribution; the IBM 2013 header that
  was copy-pasted by mistake is replaced.
- QueryUtils.cs, WhereClauseImpl.cs, SortTermsImpl.cs,
  QueryBasicTest.cs, Grammars/OslcWhere.g (modified): line appended
  after the existing IBM Corporation header; all other attributions
  and the Contributors block preserved.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@berezovskyi berezovskyi marked this pull request as ready for review May 17, 2026 14:21
@berezovskyi
Copy link
Copy Markdown
Member Author

@kuribara-hideaki @nenaaki @m-yoko I noticed that you used OSLC4Net in the past and made improvements around the robustness of the OSLC Query parsing. May I ask you for help to review this PR?

Are you still using the library? If so, could you please describe what is missing for you before you can switch away from your fork (I am assuming here) back to the mainline repo and our NuGet packages?

Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant