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

Improve exception reporting for null values on optional field values #205

Open
8 tasks
aj-stein-gsa opened this issue Oct 22, 2024 · 6 comments
Open
8 tasks
Assignees
Labels
enhancement New feature or request java Pull requests that update Java code

Comments

@aj-stein-gsa
Copy link
Contributor

aj-stein-gsa commented Oct 22, 2024

User Story

As a developer using this library and related tooling, when encountering an optional field value, I would like a more precise error message and controlled error behavior when such a null value is visited. I do not want a null pointer exception.

NOTE: This is a fix in the core library that is the root cause of the bug reported in GSA/fedramp-automation#787.

Goals

  • Improve error handling for users of metaschema-java based tools related to null field values
  • Gracefully fail in the occurrence of null values for a field value

Dependencies

N/A

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 Oct 22, 2024
@aj-stein-gsa aj-stein-gsa self-assigned this Oct 22, 2024
@aj-stein-gsa
Copy link
Contributor Author

@david-waltermire do we need to wrap this into the upcoming release? I do not know if we are planning that for the next day or two or we have some wiggle room. Let me know, thanks.

@david-waltermire
Copy link
Contributor

david-waltermire commented Oct 26, 2024

I can include this in the 2.0.0 release.

There are two ways to handle this.

  1. Turn this into an error when parsing, since this is caused by missing expected information in the instance. This would keep the non-null requirement on the field value. This might have a minor impact to parsing performance. (low effort)
  2. Relax the non-null requirement on field values and add checks where this value is accessed. This will still result in Metapath processing errors, but will make the API a bit more robust, potentially at the expense of performance, since additional null checks will need to be added to the code paths. (moderate effort)

I am leaning towards option 1, but would like to consider other thoughts.

@aj-stein-gsa
Copy link
Contributor Author

I can include this in the 2.0.0 release.

There are two ways to handle this.

I am leaning towards option 1, but would like to consider other thoughts.

I guess it depends on what is more accessible to developers or engineers extending tools on top of it. I guess it depends on what you want to present to the user with either option 1. Can it give relevant information to the developer/engineer sufficient context to know where in the document the issue occurs without more work and surfacing it specifically as a Metapath processing error? Can such context be given without Metapath processing and presumably Metapath location?

Generally, I am fine with Option 1, but wanted to understand a little more detail on that.

@david-waltermire david-waltermire moved this from In progress to Ready in Spec and Tooling Work Board Oct 27, 2024
@david-waltermire
Copy link
Contributor

To handle this at parse time null checking needs to be handled in the following locations:

@david-waltermire
Copy link
Contributor

I created a feature branch with a test for this.

@david-waltermire
Copy link
Contributor

#227 summarizes why this is not possible to completely fix right now. Adding to backlog.

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
Status: Backlog
Development

No branches or pull requests

2 participants