Skip to content

Replace type for all Id input parameters from [String] to [Guid] #125

Closed
@NowinskiK

Description

@NowinskiK

Problem description

Currently, all functions do use [string] as type for input parameters like WorkspaceId, WarehouseId, ***Id.
When user pass wrong value for such parameters it result in error and may cost presious time to trouble shoot.
It's best practice to use a specific type when possible:
Use Strongly-Typed .NET Framework Types

Hence, a recommendation to replace all [String] with [Guid] for all parameters with that type.

Example:

    param (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [string]$WorkspaceId,

        [Parameter(Mandatory = $false)]
        [ValidateNotNullOrEmpty()]
        [string]$LakehouseId
    )

What happened when a user provides an incorrect value (non-guid) now:
Image

Verbose logs

See above

Module Version

Pre-release

Suggested solution

Recommendation to replace all [String] with [Guid] for all parameters with that type.

Example of new code:

    param (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [Guid]$WorkspaceId,

        [Parameter(Mandatory = $false)]
        [ValidateNotNullOrEmpty()]
        [Guid]$LakehouseId
    )

What happened when a user provides an incorrect value (non-guid) after the change:

Image

This allows us to catch the error as early as possible and face further errors or (even worse) misleading output.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions