palantir / palantir/conjure-java

Conjure-generated client does not properly serialize nested aliases in PLAIN context

Open
#70 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
39
Forks
49
Avg merge
8h 22m
Merged PRs (30d)
32

Description

Generate a Conjure client using the following definition:

types:
  definitions:
    default-package: com.palantir.product
    objects:
      AliasOne:
        alias: string
      AliasTwo:
        alias: optional<AliasOne>
      AliasThree:
        alias: AliasTwo

services:
  EteService:
    name: Ete Service
    package: com.palantir.product
    base-path: /base

    endpoints:
      aliasThree:
        http: GET /aliasThree
        args:
          queryParamName:
            param-type: query
            type: AliasThree
        returns: AliasThree

Make the following client call:

eteService.aliasThree(AliasThree.of(AliasTwo.of(Optional.empty()))

Expected

Calls the endpoint with no query parameters (because serialized equivalent is Optional.empty())

Actual

Calls the endpoint with a query parameter that consists of the literal string Optional.empty

The same issue exists for non-optional calls:

eteService.aliasThree(
                AliasThree.of(AliasTwo.of(Optional.of(AliasOne.of("hello"))))

Expected

Query parameter value is hello

Actual

Query parameter value is Optional[hello]


Based on this, it appears that PLAIN serialization does not properly work for alias types nested in optionals.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Generate the client from the provided Conjure definition and reproduce the aliasThree calls in the generated client. Start at the PLAIN serialization path used for the query parameter; done means Optional.empty produces no parameter and the nested value produces hello rather than Optional[hello].

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.