From 34f92a831a74ff0d00c013bacbd7858c495ebdbe Mon Sep 17 00:00:00 2001
From: Michelle Ark <MichelleArk@users.noreply.github.com>
Date: Wed, 4 Dec 2024 12:38:03 -0500
Subject: [PATCH] Access DEBUG flag through get_flags() (#11069) (#11096)

---
 .changes/unreleased/Fixes-20241128-162936.yaml | 6 ++++++
 core/dbt/parser/manifest.py                    | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)
 create mode 100644 .changes/unreleased/Fixes-20241128-162936.yaml

diff --git a/.changes/unreleased/Fixes-20241128-162936.yaml b/.changes/unreleased/Fixes-20241128-162936.yaml
new file mode 100644
index 00000000000..a439875c223
--- /dev/null
+++ b/.changes/unreleased/Fixes-20241128-162936.yaml
@@ -0,0 +1,6 @@
+kind: Fixes
+body: Access DBUG flag more consistently with the rest of the codebase in ManifestLoader
+time: 2024-11-28T16:29:36.236729+01:00
+custom:
+    Author: Threynaud
+    Issue: "11068"
diff --git a/core/dbt/parser/manifest.py b/core/dbt/parser/manifest.py
index 98e7cea6257..72f328a0bbe 100644
--- a/core/dbt/parser/manifest.py
+++ b/core/dbt/parser/manifest.py
@@ -627,9 +627,11 @@ def check_for_spaces_in_resource_names(self):
             else EventLevel.WARN
         )
 
+        flags = get_flags()
+
         for node in self.manifest.nodes.values():
             if " " in node.name:
-                if improper_resource_names == 0 or self.root_project.args.DEBUG:
+                if improper_resource_names == 0 or flags.DEBUG:
                     fire_event(
                         SpacesInResourceNameDeprecation(
                             unique_id=node.unique_id,
@@ -641,7 +643,6 @@ def check_for_spaces_in_resource_names(self):
 
         if improper_resource_names > 0:
             if level == EventLevel.WARN:
-                flags = get_flags()
                 dbt.deprecations.warn(
                     "resource-names-with-spaces",
                     count_invalid_names=improper_resource_names,