Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smithy ast caching maven dependencies is incorrect #2537

Open
mullermp opened this issue Feb 22, 2025 · 2 comments
Open

smithy ast caching maven dependencies is incorrect #2537

mullermp opened this issue Feb 22, 2025 · 2 comments

Comments

@mullermp
Copy link
Contributor

It appears incorrect cache keys are used for maven dependencies in smithy build json files. I'm able to work around this by "touching" the config file - I suppose this somehow busts the cache.

Reproduction:

test1.json

{
  "version": "1.0",
  "maven": {
    "dependencies": [
      "software.amazon.smithy:smithy-rules-engine:[1.0,2.0)"
    ]
  }
}

test2.json

{
  "version": "1.0",
  "maven": {
    "dependencies": [
      "software.amazon.smithy:smithy-protocol-traits:[1.0,2.0)"
    ]
  }
}

test1.smithy

$version: "2.0"

namespace smithy.tests.endpointrules.defaultvalues

use smithy.rules#clientContextParams

@clientContextParams(
    bar: {type: "string", documentation: "a client string parameter"}
)
service FizzBuzz {}

test2.smithy

$version: "2"

namespace smithy.ruby.tests

use smithy.protocols#rpcv2Cbor

@rpcv2Cbor
service Service {}

Try running:

smithy ast --debug --config test1.json test1.smithy
smithy ast --debug --config test2.json test2.smithy

If you don't see an error, run test1 again.
Bust cache with:

touch test2.json
touch test1.json

Whatever ast command you run first will succeed, the later one appears to fail.

@mtdowling
Copy link
Member

I suspect the caching folder needs to be scoped to config files. I think the current implementation assumes a project configuration file is used rather than explicit configs. A quicker solution to fix the bug could be to not use caching when an explicit config is given via --config.

@mullermp
Copy link
Contributor Author

I am running smithy AST in a directory to make json fixtures for testing. My logic will discover smithy build json files in the folder hierarchy. Sometimes I may invoke the command with multiple config files. My understanding is that they are merged in that case.

I would think you do want caching somehow to avoid pulling maven dependencies each time. In some cases I may have common smithy build (like in an endpoints folder) that pulls in endpoint rules traits for all of the sub directories. Whatever solution you decide, it should handle the multiple config file case I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants