Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions console-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,46 @@ mod tests {
assert!(!index.data.is_empty());
}

#[test]
fn test_all_placeholders_present_in_embedded_files() {
let placeholders = [
"VITE_IDP_AUTHORITY_PLACEHOLDER",
"VITE_IDP_CLIENT_ID_PLACEHOLDER",
"VITE_IDP_REDIRECT_PATH_PLACEHOLDER",
"VITE_IDP_SCOPE_PLACEHOLDER",
"VITE_IDP_RESOURCE_PLACEHOLDER",
"VITE_IDP_POST_LOGOUT_REDIRECT_PATH_PLACEHOLDER",
"VITE_ENABLE_AUTHENTICATION_PLACEHOLDER",
"VITE_ENABLE_PERMISSIONS_PLACEHOLDER",
"VITE_IDP_TOKEN_TYPE_PLACEHOLDER",
"VITE_BASE_URL_PREFIX_PLACEHOLDER",
"VITE_APP_ICEBERG_CATALOG_URL_PLACEHOLDER",
];

let files: Vec<_> = LakekeeperConsole::iter().collect();
let mut found = Vec::new();
let mut missing = Vec::new();

for placeholder in &placeholders {
let is_found = files.iter().any(|file_path| {
LakekeeperConsole::get(file_path).is_some_and(|file| {
std::str::from_utf8(&file.data)
.is_ok_and(|content| content.contains(placeholder))
})
});
Comment on lines +210 to +220
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Gzipped assets are not decompressed — placeholders will be falsely reported as missing

LakekeeperConsole::iter() yields the raw stored paths (including .js.gz, .html.gz, etc. produced by build.rs). LakekeeperConsole::get(file_path) then returns the raw compressed bytes, and std::str::from_utf8 fails on gzip binary content, so is_ok_and(…) is always false for those entries. In a build where large JS assets are stored only as .gz, all 11 placeholders would be reported as missing — a false failure that directly defeats the test's purpose.

The project already exposes the two helpers needed to fix this: the #[cfg(test)]-gated embedded_iter() (which strips .gz suffixes, lines 81–89) and the public embedded() (which decompresses transparently, lines 64–75). test_get_all_files uses exactly these two; the new test should too.

🐛 Proposed fix
-        let files: Vec<_> = LakekeeperConsole::iter().collect();
+        let files: Vec<_> = embedded_iter().collect();
         let mut found = Vec::new();
         let mut missing = Vec::new();
 
         for placeholder in &placeholders {
             let is_found = files.iter().any(|file_path| {
-                LakekeeperConsole::get(file_path).is_some_and(|file| {
+                embedded(file_path.as_ref()).is_some_and(|file| {
                     std::str::from_utf8(&file.data)
                         .is_ok_and(|content| content.contains(placeholder))
                 })
             });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let files: Vec<_> = LakekeeperConsole::iter().collect();
let mut found = Vec::new();
let mut missing = Vec::new();
for placeholder in &placeholders {
let is_found = files.iter().any(|file_path| {
LakekeeperConsole::get(file_path).is_some_and(|file| {
std::str::from_utf8(&file.data)
.is_ok_and(|content| content.contains(placeholder))
})
});
let files: Vec<_> = embedded_iter().collect();
let mut found = Vec::new();
let mut missing = Vec::new();
for placeholder in &placeholders {
let is_found = files.iter().any(|file_path| {
embedded(file_path.as_ref()).is_some_and(|file| {
std::str::from_utf8(&file.data)
.is_ok_and(|content| content.contains(placeholder))
})
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@console-rs/src/lib.rs` around lines 210 - 220, The test is iterating raw
stored paths and calling LakekeeperConsole::get which returns gzipped bytes, so
UTF-8 checks always fail; replace use of LakekeeperConsole::iter() with the
test-only LakekeeperConsole::embedded_iter() (which strips .gz suffixes) and
call LakekeeperConsole::embedded(name) instead of
LakekeeperConsole::get(file_path) so you receive decompressed content before
running std::str::from_utf8(...).contains(placeholder); update references in the
loop to use embedded_iter() and embedded() (or their returned bytes) so
placeholders are checked against decompressed text.

if is_found {
found.push(*placeholder);
} else {
missing.push(*placeholder);
}
}

assert!(
missing.is_empty(),
"Placeholders not found in any embedded console file — frontend build likely no longer emits them, so templating in get_file() is a no-op.\n missing: {missing:#?}\n found: {found:#?}"
);
}

#[test]
fn test_get_all_files() {
let config = LakekeeperConsoleConfig {
Expand Down
Loading