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

Use of explicit qualified name, not namespace binding prefix, throws an exception #292

Open
aj-stein-gsa opened this issue Dec 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@aj-stein-gsa
Copy link
Contributor

aj-stein-gsa commented Dec 12, 2024

Describe the bug

In Metapath, if one uses an explicit qualified name for a field, flag, or assembly, a compilation exception occurs (MPST0003).

Who is the bug affecting

Developers of Metaschema-enabled tooling and engineers who write Metapath with explicit use of qualified names for querying specific data elements in Metaschema-bound document instances by their namespace explicitly.

How do we replicate this issue

  1. Write a Metapath-based constraint with a @target with a qualified name, such as
  2. Use the metaschema-java library or CLI to validate the constraint.
  3. Locate one or more of the following exceptions.

NOTE: The full example code can be found in the repro branch below.

https://github.com/aj-stein-gsa/fedramp-automation/tree/bug-metaschema-java-292-example-qname-repro

A expect constraint with id 'has-authorization-boundary-diagram-link-href-target', matching the item at path '/system-security-plan/control-implementation[1]/implemented-requirement[43]/link[2]', resulted in an unexpected error. MPST0003: Unable to compile Metapath '.[ancestor::Q{http://csrc.nist.gov/ns/oscal/1.0}authorization-boundary and @rel='diagram']'
gov.nist.secauto.metaschema.core.metapath.StaticMetapathException: MPST0003: Unable to compile Metapath '.[ancestor::Q{http://csrc.nist.gov/ns/oscal/1.0}authorization-boundary and @rel='diagram']'
        at gov.nist.secauto.metaschema.core.metapath.MetapathExpression.compile(MetapathExpression.java:94) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.IMetapathExpression.compile(IMetapathExpression.java:136) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.impl.AbstractConstraint.lambda$new$0(AbstractConstraint.java:88) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at nl.talsmasoftware.lazy4j.Lazy.forceEagerEvaluation(Lazy.java:85) ~[nl.talsmasoftware.lazy4j-2.0.0.jar:?]
        at nl.talsmasoftware.lazy4j.Lazy.get(Lazy.java:101) ~[nl.talsmasoftware.lazy4j-2.0.0.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.impl.AbstractConstraint.getTargetMetapath(AbstractConstraint.java:141) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.impl.AbstractConstraint.matchTargets(AbstractConstraint.java:149) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator.validateExpect(DefaultConstraintValidator.java:650) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator.validateAssembly(DefaultConstraintValidator.java:208) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator$Visitor.visitAssembly(DefaultConstraintValidator.java:1018) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator$Visitor.visitAssembly(DefaultConstraintValidator.java:955) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem.accept(IAssemblyNodeItem.java:76) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.item.node.AbstractNodeItemVisitor.visitModelChildren(AbstractNodeItemVisitor.java:73) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.item.node.AbstractNodeItemVisitor.visitAssembly(AbstractNodeItemVisitor.java:173) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator$Visitor.visitAssembly(DefaultConstraintValidator.java:1019) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator$Visitor.visitAssembly(DefaultConstraintValidator.java:955) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem.accept(IAssemblyNodeItem.java:76) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.item.node.AbstractNodeItemVisitor.visitModelChildren(AbstractNodeItemVisitor.java:73) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.item.node.AbstractNodeItemVisitor.visitAssembly(AbstractNodeItemVisitor.java:173) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator$Visitor.visitAssembly(DefaultConstraintValidator.java:1019) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator$Visitor.visitAssembly(DefaultConstraintValidator.java:955) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem.accept(IAssemblyNodeItem.java:76) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.item.node.AbstractNodeItemVisitor.visitModelChildren(AbstractNodeItemVisitor.java:73) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.item.node.AbstractNodeItemVisitor.visitAssembly(AbstractNodeItemVisitor.java:173) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator$Visitor.visitAssembly(DefaultConstraintValidator.java:1019) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator$Visitor.visitAssembly(DefaultConstraintValidator.java:955) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem.accept(IAssemblyNodeItem.java:76) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator.validate(DefaultConstraintValidator.java:142) [dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.databind.IBindingContext.validate(IBindingContext.java:502) [dev.metaschema.java.metaschema-databind-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.databind.IBindingContext.validate(IBindingContext.java:474) [dev.metaschema.java.metaschema-databind-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.databind.IBindingContext.validateWithConstraints(IBindingContext.java:558) [dev.metaschema.java.metaschema-databind-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.cli.commands.AbstractValidateContentCommand$AbstractValidationCommandExecutor.validate(AbstractValidateContentCommand.java:268) [dev.metaschema.java.metaschema-cli-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.cli.commands.AbstractValidateContentCommand$AbstractValidationCommandExecutor.execute(AbstractValidateContentCommand.java:222) [dev.metaschema.java.metaschema-cli-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor$CallingContext.invokeCommand(CLIProcessor.java:521) [dev.metaschema.java.cli-processor-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor$CallingContext.processCommand(CLIProcessor.java:497) [dev.metaschema.java.cli-processor-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor.parseCommand(CLIProcessor.java:234) [dev.metaschema.java.cli-processor-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor.process(CLIProcessor.java:210) [dev.metaschema.java.cli-processor-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.oscal.tools.cli.core.CLI.runCli(CLI.java:83) [dev.metaschema.oscal.oscal-cli-enhanced-2.5.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.oscal.tools.cli.core.CLI.main(CLI.java:48) [dev.metaschema.oscal.oscal-cli-enhanced-2.5.0-SNAPSHOT.jar:?]
Caused by: org.antlr.v4.runtime.misc.ParseCancellationException: line 1:13 mismatched input '{' expecting ']'
        at gov.nist.secauto.metaschema.core.metapath.antlr.FailingErrorListener.syntaxError(FailingErrorListener.java:25) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41) ~[org.antlr.antlr4-runtime-4.13.2.jar:4.13.2]
        at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544) ~[org.antlr.antlr4-runtime-4.13.2.jar:4.13.2]
        at org.antlr.v4.runtime.DefaultErrorStrategy.reportInputMismatch(DefaultErrorStrategy.java:327) ~[org.antlr.antlr4-runtime-4.13.2.jar:4.13.2]
        at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:139) ~[org.antlr.antlr4-runtime-4.13.2.jar:4.13.2]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.predicate(Metapath10.java:3332) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.postfixexpr(Metapath10.java:3134) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.stepexpr(Metapath10.java:2420) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.relativepathexpr(Metapath10.java:2352) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.pathexpr(Metapath10.java:2301) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.simplemapexpr(Metapath10.java:2216) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.valueexpr(Metapath10.java:2073) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.unaryexpr(Metapath10.java:2036) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.arrowexpr(Metapath10.java:1947) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.castexpr(Metapath10.java:1879) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.castableexpr(Metapath10.java:1822) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.treatexpr(Metapath10.java:1765) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.instanceofexpr(Metapath10.java:1708) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.intersectexceptexpr(Metapath10.java:1641) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.unionexpr(Metapath10.java:1568) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.multiplicativeexpr(Metapath10.java:1495) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.additiveexpr(Metapath10.java:1414) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.rangeexpr(Metapath10.java:1353) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.stringconcatexpr(Metapath10.java:1295) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.comparisonexpr(Metapath10.java:1212) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.andexpr(Metapath10.java:1149) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.orexpr(Metapath10.java:1088) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.exprsingle(Metapath10.java:561) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.expr(Metapath10.java:464) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.antlr.Metapath10.metapath(Metapath10.java:214) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.MetapathExpression.compile(MetapathExpression.java:80) ~[dev.metaschema.java.metaschema-core-2.2.0-SNAPSHOT.jar:?]
        ... 38 more

Expected behavior (i.e. solution)

The QName is honored and the path successfully evaluates on the explicitly identified QName.

Other comments

No response

@aj-stein-gsa aj-stein-gsa added the bug Something isn't working label Dec 12, 2024
aj-stein-gsa added a commit to aj-stein-gsa/fedramp-automation that referenced this issue Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: To Triage
Development

No branches or pull requests

1 participant