Generated Elixir module names clash
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 178
- Forks
- 96
- Avg merge
- 6d 23h
- Merged PRs (30d)
- 3
Description
Preflight checklist
- I could not find a solution in the existing issues, docs, nor discussions.
- I agree to follow this project's Code of Conduct.
- I have read and am following this repository's Contribution Guidelines.
- This issue affects my Ory Network project.
- I have joined the Ory Community Slack.
- I am signed up to the Ory Security Patch Newsletter.
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
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}
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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