Skip to content

fix: insert Module.withDependencies in correct order - #9052

Merged
jedevc merged 4 commits into
dagger:mainfrom
jedevc:install-correct-order
Jan 14, 2025
Merged

jedevc merged 4 commits into
dagger:mainfrom
jedevc:install-correct-order

Conversation

@jedevc

@jedevc jedevc commented Nov 25, 2024

Copy link
Copy Markdown
Contributor

Previously, calling dagger install with no name would bizarrely insert it into the beginning of the dagger.json dependencies field. Then calling dagger develop would fix it.

This was an absurd little pet-peeve, so took some time to fix it - it will be nice when we can clean up ModuleSource.resolveFromCaller, since trying to understand that for this bug was by far the trickiest bit to actually understand and track.

This is what was happening:

  • We call updateDeps to update our dependencies.
  • We were calling ModuleSource.dependencies (which merges withDependencies nicely) and getting all ordered dependencies.
  • However, no name was specified in the withDependencies call, so the name was actually the empty string - so was appearing first in the lexigraphic sort.
  • Then, later in updateDeps, we fill in the missing name - this is correct, but is now too late for the sort, so we have the wrong order.

The solution is fairly simply - dependencies should fill in missing names if possible.

We could have added updateDeps as an alternative, but this is actually not great, since this means that dependencies would still be returning dependencies that have no name - which is a potential footgun for the next person coming along.

@jedevc
jedevc requested a review from sipsma November 25, 2024 16:42
@sipsma

sipsma commented Dec 4, 2024

Copy link
Copy Markdown
Contributor

Looks like there's some legit test failures here, also this is worth it's own test coverage too

@jedevc
jedevc force-pushed the install-correct-order branch 2 times, most recently from 8f82e6b to 15ed238 Compare December 4, 2024 17:11
@jedevc

jedevc commented Dec 4, 2024

Copy link
Copy Markdown
Contributor Author

Fixed most of the tests and added a new one to check the sorted behavior.

Noticed one of them is still failing, will investigate though.

@jedevc
jedevc force-pushed the install-correct-order branch 2 times, most recently from 62e9240 to 197465a Compare December 6, 2024 11:18
@jedevc
jedevc force-pushed the install-correct-order branch from 197465a to c8e2f21 Compare December 6, 2024 12:15
@jedevc jedevc added this to the v0.15.0 milestone Dec 6, 2024
@jedevc

jedevc commented Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

Think all of these are fixed now!

@jedevc jedevc modified the milestones: v0.15.0, v0.15.1 Dec 10, 2024
@jedevc

jedevc commented Dec 10, 2024

Copy link
Copy Markdown
Contributor Author

This isn't an urgent change, moving this out of the milestone.

@jedevc
jedevc force-pushed the install-correct-order branch from c8e2f21 to ac97c76 Compare December 12, 2024 11:51
@jedevc jedevc modified the milestones: v0.15.1, v0.15.2 Dec 13, 2024
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@jedevc jedevc removed the kind/stale label Dec 28, 2024
@jedevc
jedevc force-pushed the install-correct-order branch from ac97c76 to 5d87af3 Compare January 6, 2025 14:23
@jedevc
jedevc requested a review from marcosnils January 6, 2025 15:22
jedevc added 4 commits January 6, 2025 15:37
Previously, calling `dagger install` with no name would bizarrely insert
it into the beginning of the `dagger.json` `dependencies` field. Then
calling `dagger develop` would fix it.

This is what was happening:
- We call `updateDeps` to update our dependencies.
- We were calling `ModuleSource.dependencies` (which merges
  `withDependencies` nicely) and getting all ordered dependencies.
- However, no name was specified in the `withDependencies` call, so the
  name was actually the empty string - so was appearing first in the
  lexigraphic sort.
- Then, later in `updateDeps`, we fill in the missing name - this is
  correct, but is now too late for the sort, so we have the wrong order.

The solution is fairly simply - `dependencies` should fill in missing
names if possible.

We *could* have added `updateDeps` as an alternative, but this is
actually not great, since this means that `dependencies` would still be
returning `dependencies` that have no name - which is a potential
footgun for the next person coming along.

Signed-off-by: Justin Chadwell <[email protected]>
There's a lot of shared logic here - which I hadn't realized was
duplicated at first and needed to be changed in two places - this
removes that need.

Signed-off-by: Justin Chadwell <[email protected]>
@jedevc
jedevc force-pushed the install-correct-order branch from 5d87af3 to fdb3eb5 Compare January 6, 2025 15:55
@jedevc jedevc added the kind/bug Something isn't working label Jan 6, 2025
@jedevc
jedevc merged commit 76bdb19 into dagger:main Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants