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

function: Add validation to prevent collection parameters/return definitions from having missing element types #965

Closed
austinvalle opened this issue Mar 20, 2024 · 1 comment · Fixed by #991
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@austinvalle
Copy link
Member

Module version

v1.6.0

Use-cases

#931 will introduce a new internal interface fwfunction.ParameterWithValidateImplementation and fwfunction.ReturnWithValidateImplementation that will enable us to implement logic for validating function parameter and return definitions.

We should introduce validation on all collection parameter and return definitions to ensure that element types are populated.

resp.Definition = function.Definition{
    Parameters: []function.Parameter{
        function.ListParameter{
            Name: "list",
            // Missing element type!
        },
    },
    Return: function.ListReturn{
        // Missing element type!
    },
}

Proposal

Implementation could look similar to collection attributes, such as ListAttribute:

if a.CustomType == nil && a.ElementType == nil {
resp.Diagnostics.Append(fwschema.AttributeMissingElementTypeDiag(req.Path))
}

We should add this to:

  • ListParameter
  • ListReturn
  • MapParameter
  • MapReturn
  • SetParameter
  • SetReturn

References

@austinvalle austinvalle added the enhancement New feature or request label Mar 20, 2024
@bflad bflad added this to the v1.7.0 milestone Mar 20, 2024
@bflad bflad modified the milestones: v1.7.0, v1.8.0 Mar 21, 2024
@austinvalle austinvalle modified the milestones: v1.8.0, v1.9.0 Apr 17, 2024
@bflad bflad self-assigned this Apr 23, 2024
bflad added a commit that referenced this issue Apr 23, 2024
…ame validation

Reference: #965
Reference: #967

The framework will now raise implementation errors if a function parameter or return definition is missing underlying type information (e.g. collection element type or object attribute type).
bflad added a commit that referenced this issue Apr 24, 2024
…ame validation (#991)

Reference: #965
Reference: #967

The framework will now raise implementation errors if a function parameter or return definition is missing underlying type information (e.g. collection element type or object attribute type). Only framework types are considered in the initial implementation.
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
2 participants