Skip to content

Conversation

@sfc-gh-mraba
Copy link
Contributor

@sfc-gh-mraba sfc-gh-mraba commented Oct 1, 2025

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.
  • I've described my changes in the documentation.

Changes description

This PR refactors the Snowflake CLI configuration management by removing the module-level CONFIG_MANAGER singleton and replacing it with a factory-based approach managed through the CliGlobalContext. This change improves testability and eliminates test flakiness caused by shared global state.

@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-2306184-ng-config-support-3 branch from 54e7ad4 to 52151dd Compare October 2, 2025 08:37
@sfc-gh-mraba sfc-gh-mraba self-assigned this Oct 2, 2025
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-2306184-ng-config-support-3 branch 2 times, most recently from 99a467d to c32692c Compare October 13, 2025 06:57
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-2306184-ng-config-support-3 branch from 68ccdbc to ee5e0ce Compare October 21, 2025 08:42
@sfc-gh-mraba sfc-gh-mraba marked this pull request as ready for review October 21, 2025 08:43
@sfc-gh-mraba sfc-gh-mraba requested a review from a team as a code owner October 21, 2025 08:43
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-2306184-ng-config-support-3 branch from ee5e0ce to 2484c26 Compare October 21, 2025 12:34
Copy link
Contributor

@sfc-gh-jwilkowski sfc-gh-jwilkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left 1 important question about connections_file_override which does not seem to be needed (maybe yet?). Otherwise a general comment would be about recurring issues across this PR:

  • lots of local imports, where I don't think most of them would cause circular deps
  • lots of comments that don't add much value
  • I've seen this pattern repeating several times - maybe path resolver could go into SecurePath so that we can avoid repeating those?
# Resolve Windows short paths to prevent cleanup issues
resolved_tmp_dir = path_resolver(tmp_dir)
config_path = Path(resolved_tmp_dir) / "config.toml"

Otherwise, looks great!

@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-2306184-ng-config-support-3 branch from 2484c26 to 66356e5 Compare October 23, 2025 12:57
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-2306184-ng-config-support-3 branch from af729e4 to 304a27a Compare November 3, 2025 08:05
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-2306184-ng-config-support-3 branch from 304a27a to 927bc4f Compare November 17, 2025 09:10
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-2306184-ng-config-support-3 branch 2 times, most recently from 0454d1a to c02a716 Compare December 2, 2025 12:33
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-2306184-ng-config-support-3 branch 2 times, most recently from 0fa6b1d to 1ee50c4 Compare December 9, 2025 15:27
hidden=os.environ.get(ALTERNATIVE_CONFIG_ENV_VAR, "").lower()
not in ("1", "true", "yes", "on"),
)
def show_config_sources(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I'm thinking about this command one of the primary use cases would be "I have connection x defined in different places, how can I see where it's taking it's values from". what do you think about providing --connection flag to serve that instead of key argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in future. This PR is already huge.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then for now I'd only suggest to make key an option not an argument

"-d",
help="Show detailed resolution chains for all sources consulted.",
),
export_file: Optional[Path] = typer.Option(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what I understood this option and related logic should be removed

@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-2306184-ng-config-support-3 branch from 1ee50c4 to 5d3c16a Compare December 15, 2025 09:07
Comment on lines +81 to +86
Example:
Input:
connections = {"dev": {"account": "dev_acc", "user": "dev_user"}}
params = {"user": "override_user", "password": "new_pass"}
Output:
{"dev": {"account": "dev_acc", "user": "override_user", "password": "new_pass"}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels confusing, at least I interpreted it as if the top level settings would override what's defined on particular connection level

return cls._apply_default_connection_fallback(result)

@classmethod
def _apply_default_connection_fallback(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sfc-gh-mraba here's the logic that actually takes general settings and applies specifics overlay

Comment on lines +137 to +143
def attach_observer(self, observer: ResolutionObserver) -> None:
"""Attach a new observer at runtime."""
self._observers.append(observer)
if isinstance(observer, TelemetryObserver):
self._telemetry_observer = observer
if isinstance(observer, ResolutionHistoryTracker):
self._history_observer = observer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method seems to be redundant. It's only used once in ensure_history_tracking to attach ResolutionHistoryTracker. Those 3 lines might just as well end up in ensure_history_tracking

Comment on lines +149 to +150
Returns:
True if a new tracker was attached and observers should be reset.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems that this return value is needed only for resetting - why not do it in this method? Feels weird when you call ensure_something method and it returns you false even though that thing is ensured

for observer in self._observers:
getattr(observer, method_name)(*args, **kwargs)

def add_source(self, source: "ValueSource") -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code?

"""
return [s for s in self._sources if s.source_type is source_type]

def _record_discoveries(self, source_values: Dict[str, ConfigValue]) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code

@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-2306184-ng-config-support-3 branch from e8f727c to b599018 Compare December 22, 2025 07:40
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

Successfully merging this pull request may close these issues.

3 participants