danielgtaylor / danielgtaylor/huma

How should nullable query params be handled without pointers?

Open
#393 7 comments 2 reactions 0 assignees View on GitHub
question
Dominant language
Go
Stars
4.4k
Forks
285
Avg merge
40m
Merged PRs (30d)
1

Description

Hey! Excellent project, I've been reworking various projects to make use of Huma and have loved it (despite the initial learning curve).

We use a filter struct that gets passed through various layers, and use pointers for each field to support nullable and empty values. [Unfortunately, Huma doesn't support pointers for query params.](https://github.com/danielgtaylor/huma/blob/e66ddf3644c99f8363d6ad61e9b0c58d24f5c16e/huma.go#L120) I thought I could just switch to checking if a value was empty, but then ran into the issue of booleans. How should this be approached without a hacky workaround? I did read the `TODO` in the codebase as to why pointers aren't _currently_ supported :(

Thanks in advance!

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue points to huma.go around line 120 and the existing TODO; read that code and the linked discussion first. Define an agreed approach for representing nullable query parameters, especially booleans, and confirm the behavior with maintainers before implementation. Done means the supported behavior and approach are accepted and documented or implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.