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

Validate package subsection in package.json #597

Open
wants to merge 41 commits into
base: v0.5
Choose a base branch
from

Conversation

nandorsoma
Copy link

This PR introduces validation for config files, with initial focus on validating packages being uploaded to the repository. The ultimate goal is to make it extendable for the validation of the entire Sqrl config, hence its placement within SqrlConfigCommons. Here are some considerations driving the current design:

  • Individual vs. combined configurations: We can validate either individual configurations or the resultant CombinedConfiguration. While the CombinedConfiguration is critical for us, providing validation feedback on individual files may be more beneficial to the user. Hence, every file is validated separately.

  • Precedence in configurations: Given that if a section is present across multiple files, one of them takes precedence over the others, we need to consider if this is valid for the "package" section. Should there be only one "package" section? If so, we may require a "strict" combination rule which doesn't allow overrides for certain use-cases. This requires further thoughts and feedback.

  • Validation point: Validation could be performed either before parsing the file into Configuration (validating raw user input) or after (validating Configuration object). The latter avoids duplicate file reads from the disk and has been implemented for now.

  • Configuration to JsonObject: The conversion of Configuration to JsonObject required a custom converter. An alternate approach would utilize SqrlConfigCommons.toMap and pass the result to the JsonObject constructor, necessitating minor modifications to the toMap method. This alternate approach was not chosen to avoid touch-points with getKeys and getAllKeys, and to retain code readability despite the minor duplication in function.

I look forward to further discussions on these points, particularly on the potential implementation of a "strict" combination rule and the preferred approach for converting Configuration to JsonObject.

mbroecheler and others added 30 commits March 27, 2024 10:23
Signed-off-by: Matthias Broecheler <[email protected]>
…need to discovery.

Signed-off-by: Matthias Broecheler <[email protected]>
Signed-off-by: Matthias Broecheler <[email protected]>
Signed-off-by: Matthias Broecheler <[email protected]>
… primary keys for mutations.

Signed-off-by: Matthias Broecheler <[email protected]>
Signed-off-by: Matthias Broecheler <[email protected]>
Signed-off-by: Matthias Broecheler <[email protected]>
Signed-off-by: Matthias Broecheler <[email protected]>
Signed-off-by: Matthias Broecheler <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
Signed-off-by: Matthias Broecheler <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
Signed-off-by: Matthias Broecheler <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
* Add test infra

Signed-off-by: Daniel Henneberger <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
* Update UseCaseTest

Signed-off-by: Daniel Henneberger <[email protected]>

* Update snaps

Signed-off-by: Daniel Henneberger <[email protected]>

* Fix casing

Signed-off-by: Daniel Henneberger <[email protected]>

---------

Signed-off-by: Daniel Henneberger <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
henneberger and others added 10 commits April 29, 2024 14:12
* Expand profiles

Signed-off-by: Daniel Henneberger <[email protected]>

* Add jdbc 1.18

Signed-off-by: Daniel Henneberger <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
* moving, updating and deleting old use case tests

Signed-off-by: Matthias Broecheler <[email protected]>

* completed test case migration. Need to add test hints and graphql queries

Signed-off-by: Matthias Broecheler <[email protected]>

* Added test cases and queries

Signed-off-by: Matthias Broecheler <[email protected]>

* Updating snapshots

Signed-off-by: Matthias Broecheler <[email protected]>

* Changed test case name

Signed-off-by: Matthias Broecheler <[email protected]>

* Delete old files

Signed-off-by: Matthias Broecheler <[email protected]>

* Rebase and update tests

Signed-off-by: Daniel Henneberger <[email protected]>

* Fix some tests

Signed-off-by: Daniel Henneberger <[email protected]>

* Updated test cases

Signed-off-by: Matthias Broecheler <[email protected]>

* Improve snapshot util to show full diff and add line numbers. Update snapshots

Signed-off-by: Matthias Broecheler <[email protected]>

* Update serializer, small bug fixes

Signed-off-by: Daniel Henneberger <[email protected]>

* Migrate json to jsonnode

Signed-off-by: Daniel Henneberger <[email protected]>

* Update snaps

Signed-off-by: Daniel Henneberger <[email protected]>

* Serialize json with bytes

Signed-off-by: Daniel Henneberger <[email protected]>

* External test

Signed-off-by: Matthias Broecheler <[email protected]>

* Readd default test dir

Signed-off-by: Daniel Henneberger <[email protected]>

* Only include graphql schema if there is a tests folder

Signed-off-by: Daniel Henneberger <[email protected]>

* Made test delay configurable through env variable

Signed-off-by: Matthias Broecheler <[email protected]>

* Fixed and extended conference test.

Signed-off-by: Matthias Broecheler <[email protected]>

* Making clickstream test deterministic. Updating snapshots.

Signed-off-by: Matthias Broecheler <[email protected]>

* Include function qualifier when cloning sqlcall nodes

Signed-off-by: Daniel Henneberger <[email protected]>

* Update snaps, remove stack trace on failure

Signed-off-by: Daniel Henneberger <[email protected]>

* Update snapshot

Signed-off-by: Daniel Henneberger <[email protected]>

* Add flink 1.17 profile

Signed-off-by: Daniel Henneberger <[email protected]>

* Don't format numbers, fix profile override

Signed-off-by: Daniel Henneberger <[email protected]>

* updating test cases

Signed-off-by: Matthias Broecheler <[email protected]>

* Bump watermark back to 0

Signed-off-by: Daniel Henneberger <[email protected]>

* Update snaps

Signed-off-by: Daniel Henneberger <[email protected]>

---------

Signed-off-by: Matthias Broecheler <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
Co-authored-by: Daniel Henneberger <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
* initial flexible schema inference preprocessor

Signed-off-by: Matthias Broecheler <[email protected]>

* updated snapshots

Signed-off-by: Matthias Broecheler <[email protected]>

* Make preprocessors resolve through DI

Signed-off-by: Daniel Henneberger <[email protected]>

* Fixed templating bug in vertx kafka subscription configuration

Signed-off-by: Matthias Broecheler <[email protected]>

* Adding test case for FlexibleSchemaInferencePreprocessor

Signed-off-by: Matthias Broecheler <[email protected]>

* Adding test case for FlexibleSchemaInferencePreprocessor and CopyStaticDataPreprocessor

Signed-off-by: Matthias Broecheler <[email protected]>

* Remove old discovery code.

Signed-off-by: Matthias Broecheler <[email protected]>

* Filter out empty lines in JsonRecordReader

Signed-off-by: Matthias Broecheler <[email protected]>

---------

Signed-off-by: Matthias Broecheler <[email protected]>
Signed-off-by: Daniel Henneberger <[email protected]>
Co-authored-by: Daniel Henneberger <[email protected]>
Implementing support for the repository, including both public and private packages

---------

Signed-off-by: Daniel Henneberger <[email protected]>
},
"version": {
"type": "string",
"pattern": "^(\\d+\\.\\d+\\.\\d+)$"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to enforce a pattern in versioning or is it enough if it is a string?

Base automatically changed from v0.5-RC3 to v0.5 May 13, 2024 01:50
Copy link
Contributor

@mbroecheler mbroecheler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick cursory review. Not sure if this PR is still relevant but thought the comments might help to understand the context.

} catch (ConfigurationException e) {
throw localErrors.handle(e);
}
}

@SneakyThrows
private static boolean isValid(Configuration baseconfig) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SqrlConfigCommons is a general configuration class that we use to read all kinds of configuration files. The logic for validating that a file has a particular schema needs to live in a separate class to not mix concerns.

}
},
"required": [ "package" ],
"additionalProperties": false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package.json file is used to configure the datasqrl compiler. It contains lots of other configuration options.
I'm surprised that this does not break the compiler. Are you not getting test failures with this?

Copy link
Contributor

@mbroecheler mbroecheler May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I did not see the subsequent change. Regardless: Is there test coverage for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants