Currently, if one loads an http_archive from MODULE.bazel and reference things from the loaded in a target, the generated hash does not capture parameters of this http_archive. Using --fineGrainedHashExternalRepos flag can work around this issue. But it can get costly.
Under the hood this is because bazel query //external:all-targets at here does not return any repos loaded from MODULE.bazel. One way to get the modules from MODULE.bazel is to use bazel mod dump_repo_mapping followed by bazel mod show_repo @repo1 @repo2. However, currently show_repo does not support outputting machine parsable output (tracked by bazelbuild/bazel#21617).
This issue is just to track this feature. For now I can workaround the problem by feeding all the repos returned by bazel mod dump_repo_mapping to --fineGrainedHashExternalRepos to make this work.