Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear error message "The error was: stream is already consumed" for invalid Metapath expressions #289

Closed
5 tasks
aj-stein-gsa opened this issue Dec 11, 2024 · 1 comment · Fixed by #290
Closed
5 tasks
Labels
enhancement New feature or request java Pull requests that update Java code
Milestone

Comments

@aj-stein-gsa
Copy link
Contributor

aj-stein-gsa commented Dec 11, 2024

User Story

As a developer of Metaschema-enabled tooling, in order to increase the speed of development and debugging Metapath code, I need more precise error messaging where I frequently receive the error message.

"The error was: stream is already consumed"

A fairly complex example that I can to turn into a minimally viable and producible example is in this GitHub Gist.

Goals

  • More precise explanation of the kind Metapath expression that cause the error and underlying exception
  • More precision about the location in a module or external constraints file to identify which path in the module or constraint file is where the exception occurred (currently it only lists the constraint, not if it is the test, target, or message

Dependencies

No response

Acceptance Criteria

  • All website and readme documentation affected by the changes in this issue have been updated.
  • A Pull Request (PR) is submitted that fully addresses the goals of this User Story. This issue is referenced in the PR.
  • The CI-CD build process runs without any reported errors on the PR. This can be confirmed by reviewing that all checks have passed in the PR.

Revisions

No response

@aj-stein-gsa aj-stein-gsa added enhancement New feature or request java Pull requests that update Java code labels Dec 11, 2024
@david-waltermire
Copy link
Contributor

I think this is caused by reusing a cached function result sequence that is stream (default) and not list backed. Streams cannot be reused, thus the need to ensure the sequence is list backed.

Based on my current theory, the following should fix the error. Change the code in /metaschema-core/src/main/java/gov/nist/secauto/metaschema/core/metapath/function/impl/AbstractFunction.java around line 254 to:

        if (callingContext != null) {
          // ensure the result sequence is list backed
          result.getValue();
          // add result to cache
          dynamicContext.cacheResult(callingContext, result);
        }

david-waltermire added a commit to david-waltermire/metaschema-java that referenced this issue Dec 12, 2024
david-waltermire added a commit to david-waltermire/metaschema-java that referenced this issue Dec 12, 2024
@david-waltermire david-waltermire moved this from To Triage to In review in Spec and Tooling Work Board Dec 12, 2024
david-waltermire added a commit that referenced this issue Dec 12, 2024
@github-project-automation github-project-automation bot moved this from In review to Done in Spec and Tooling Work Board Dec 12, 2024
david-waltermire added a commit to david-waltermire/metaschema-java that referenced this issue Dec 19, 2024
david-waltermire added a commit to david-waltermire/metaschema-java that referenced this issue Dec 19, 2024
@david-waltermire david-waltermire added this to the v2.2.0 milestone Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request java Pull requests that update Java code
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants