ory / ory/sdk

Generated Elixir module names clash

Open
#229 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
178
Forks
96
Avg merge
6d 23h
Merged PRs (30d)
3

Description

Preflight checklist
Bug Description

Generated Elixir module names such as Ory.Connection clash. Elixir dependencies cannot override each other's Modules, but the generated code does contain the same module name in different dependencies:

Examples:

https://github.com/ory/sdk/blob/2324e5c13c45d43c7e7b3cdc5ebc86b86b627867/clients/client/elixir/lib/ory/connection.ex#L5

https://github.com/ory/sdk/blob/2324e5c13c45d43c7e7b3cdc5ebc86b86b627867/clients/hydra/elixir/lib/ory/connection.ex#L5

https://github.com/ory/sdk/blob/2324e5c13c45d43c7e7b3cdc5ebc86b86b627867/clients/keto/elixir/lib/ory/connection.ex#L5

https://github.com/ory/sdk/blob/2324e5c13c45d43c7e7b3cdc5ebc86b86b627867/clients/oathkeeper/elixir/lib/ory/connection.ex#L5

https://github.com/ory/sdk/blob/2324e5c13c45d43c7e7b3cdc5ebc86b86b627867/clients/kratos/elixir/lib/ory/connection.ex#L5

https://github.com/ory/sdk/blob/2324e5c13c45d43c7e7b3cdc5ebc86b86b627867/clients/client/elixir/lib/ory/connection.ex#L5
This is a follwup to this comment https://github.com/ory/sdk/issues/194#issuecomment-1318133766

Reproducing the bug

Create any library importing e.g. at least 2 packages:
Example snippet from mix.exs:

defp deps do
    [
     ...
      {:ory_client, github: "ory/sdk", sparse: "clients/client/elixir/"},
      {:ory_hydra, github: "ory/sdk", sparse: "clients/hydra/elixir/"}
     ]
  end
Relevant log output

when building/running lots of warnings such as this one is logged:

warning: redefining module Ory.Connection (current version loaded from /workspace/cantex_umbrella/_build/dev/lib/ory_client/ebin/Elixir.Ory.Connection.beam)
  lib/ory/connection.ex:5
Relevant configuration

Here is the Variable setting, to which I propose to add this line:

export ELIXIR_INVOKER_MODULE="Ory.${PROJECT^}"

https://github.com/ory/sdk/blob/2324e5c13c45d43c7e7b3cdc5ebc86b86b627867/scripts/prep.sh#L85
And here the line 3 should be changed to

invokerPackage: ${ELIXIR_INVOKER_MODULE}

https://github.com/ory/sdk/blob/2324e5c13c45d43c7e7b3cdc5ebc86b86b627867/config/client/elixir.yml#L1-L3

This results in package names such as Ory.Hydra.Connection

Version

latest stable versions

Additional Context

@aeneasr I'm putting here the questions I have for understanding & documentation, These are mostly issues to get the PR right.

  • How shall a PR be formulated? I'm thinking about a multi commit PR, one commit comprising the config changes, another one with each package.?
  • Does the build pipeline build all clients, all the time?
  • Are the old spec vertions built too?
  • How does the spec version map to package versions generally [if there's a rule/docs]?
  • Is there such a thing as an [aglorithmic] sdk version ?

I'll come back with a PR on this, I've already forked the sdk. The bug is easy to solve, but perhaps a followup documentation issue would benefit from those questions.

It's a rather long post, so feel free to only discuss in context of the upcoming PR.

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

Start with scripts/prep.sh around line 85 and config/client/elixir.yml, then compare the generated connection modules under clients/client/elixir and clients/hydra/elixir. Regenerate at least two clients and verify that their modules have distinct names and that the Mix build no longer reports redefining-module warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
api, build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.