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

refactor(jans-cedarling): enhance schema parser and entity creation implementation #10513

Open
rmarinn opened this issue Dec 26, 2024 · 0 comments
Assignees
Labels
comp-jans-cedarling Touching folder /jans-cedarling enhancement kind-enhancement Issue or PR is an enhancement to an existing functionality

Comments

@rmarinn
Copy link
Contributor

rmarinn commented Dec 26, 2024

Is your feature request related to a problem? Please describe.

The current Cedar Schema Parser and Entity Creation features lack some automation and validation capabilities. Specifically:

  1. Parsing schemas could be made more robust and efficient.
  2. Entity creation via Cedarling is hard to maintain since every time a new entity is introduced, a new custom function for that entity might be required depending on the entity shape.

Describe the solution you'd like

  1. Improve Cedar Schema Parser: Enhance the parser to handle edge cases, improve performance, and provide clearer error messages when schemas are invalid.
  2. Enhance Cedar Entity Creation: Update cedarling to:
    • Validate the schema against the supplied HashMap.
    • Automatically attempt to create entities based on the schema.
    • Return detailed error messages if the creation fails due to mismatches or missing data. For example, if the supplied HashMap includes a key "Access_token" with a corresponding struct, the entity builder should validate this against the schema and either create the entity or return a descriptive error.

Describe alternatives you've considered

  • Manually validating HashMap entries before invoking entity creation, which is error-prone and less efficient.
  • Writing custom logic for schema validation, which adds additional maintenance overhead and redundancy.

Additional context

Example usage:

// we define this struct which will hold all data gathered from the tokens
struct EntityBuilder;

// the creation here will probably not be as simple as calling `new` since we need to take
// note of the mappings but is initialized like this in the example for brevity.
let entity_builder = EntityBuilder::new();

entity_data.insert("Access_token", SomeStruct { /* fields */ });
match entity_builder.create_entity(&entity_data) {
    Ok(entity) => println!("Entity created: {:?}", entity),
    Err(e) => println!("Failed to create entity: {}", e),
}
@rmarinn rmarinn added comp-jans-cedarling Touching folder /jans-cedarling enhancement labels Dec 26, 2024
@rmarinn rmarinn self-assigned this Dec 26, 2024
@mo-auto mo-auto added the kind-enhancement Issue or PR is an enhancement to an existing functionality label Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-jans-cedarling Touching folder /jans-cedarling enhancement kind-enhancement Issue or PR is an enhancement to an existing functionality
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants