Skip to content

fix/ADFA-3380 template warnings#1147

Merged
davidschachterADFA merged 3 commits intostagefrom
fix/ADFA-3380-template-warnings
Apr 1, 2026
Merged

fix/ADFA-3380 template warnings#1147
davidschachterADFA merged 3 commits intostagefrom
fix/ADFA-3380-template-warnings

Conversation

@jomen-adfa
Copy link
Copy Markdown
Contributor

Show detailed warnings and errors in IDE Logs tab during template generation

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

📝 Walkthrough
  • Features

    • Template generation now collects detailed warnings/errors during loading and recipe execution and surfaces them to users via the IDE Logs tab.
    • When project creation finishes with warnings/errors, the user is shown a notification directing them to open IDE Logs for details.
    • Template provider exposes accumulated warnings so UI can surface archive- or template-specific issues immediately (e.g., TemplateListFragment displays warnings).
    • Project-opening flow propagates template issue status across activities via an Intent extra to trigger an immediate IDE notification/flash.
  • Technical changes

    • Added hasErrorsWarnings flag to project recipe results:
      • ProjectTemplateRecipeResult interface now declares val hasErrorsWarnings: Boolean.
      • ProjectTemplateRecipeResultImpl and callers updated to accept/forward this flag.
    • TemplateProviderImpl
      • New public mutable warnings: MutableList that is cleared on reload and populated during template initialization and archive reads.
      • ZipTemplateReader.read(...) now accepts a warnings: MutableList parameter and appends contextual warnings on per-template or archive failures.
    • ZipRecipeExecutor
      • Introduced structured info/warn/error logging helpers that set an internal hasErrorsWarnings flag and improved error handling for read/parse/evaluate/write/copy steps.
      • Reduced noisy debug logs; added higher-level info/warn/error messages and contextual exception wrapping.
    • UI / activity changes
      • MainActivity.openProject(...) gains hasTemplateIssues: Boolean = false and includes "HAS_TEMPLATE_ISSUES" in the Intent when true.
      • ProjectHandlerActivity checks the Intent extra and flashes the template-warnings message on startup when present.
      • TemplateDetailsFragment propagates result.hasErrorsWarnings into the call to MainActivity.openProject(...).
    • Resources
      • Added string resource msg_template_warnings: "\n\nProject creation finished with warnings/errors. Open IDE Logs for details."
  • Risks, regressions, and best-practice violations

    • Breaking/Source-compatibility risks:
      • ZipTemplateReader.read(...) signature changed (added warnings parameter) — callers must be updated; this is a source-level breaking change.
      • ProjectTemplateRecipeResult interface expanded; existing implementations may fail to compile if they don't provide the new property (although implementations in this PR provide defaults).
    • Design / API issues:
      • TemplateProviderImpl exposes a public MutableList (warnings), violating encapsulation and exposing mutable internal state. Consider returning an immutable snapshot or read-only view.
    • Logging & performance:
      • ZipRecipeExecutor increases logging and error-handling work per-template; this may have a performance impact when loading many templates—benchmark or rate-limit verbose logs if needed.
    • Error-handling coverage:
      • No tests were added for the new warning-collection, ZipRecipeExecutor error paths, or the Intent-propagation UI behavior — increases risk of undetected regressions.
    • UX considerations:
      • The notification flashes a generic message that asks users to open IDE Logs; users might miss contextual guidance. Consider richer in-place summary or direct link to relevant log lines.
  • Suggested follow-ups

    • Replace public MutableList exposure with an immutable API (List or a snapshot method).
    • Add unit/integration tests covering:
      • ZipTemplateReader warning collection when archives/templates fail.
      • ZipRecipeExecutor hasErrorsWarnings behavior and logging.
      • Intent extra propagation and ProjectHandlerActivity flash behavior.
    • Review logging verbosity and consider toggling detailed logs behind a debug flag or analytics setting.

Walkthrough

Adds propagation and UI display of template creation warnings: templates now collect warnings/errors during load/execution, results expose a hasErrorsWarnings flag, MainActivity.openProject accepts hasTemplateIssues, and the project handler activity shows a warning message when that flag is set.

Changes

Cohort / File(s) Summary
Intent flag & project open flow
app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt, app/src/main/java/com/itsaky/androidide/activities/editor/ProjectHandlerActivity.kt
MainActivity.openProject(...) gains hasTemplateIssues: Boolean = false and sets HAS_TEMPLATE_ISSUES intent extra; ProjectHandlerActivity.onCreate checks this extra and flashes msg_template_warnings when true.
Template creation call-site & UI list
app/src/main/java/com/itsaky/androidide/fragments/TemplateDetailsFragment.kt, app/src/main/java/com/itsaky/androidide/fragments/TemplateListFragment.kt
TemplateDetailsFragment passes hasTemplateIssues = result.hasErrorsWarnings when opening a created project. TemplateListFragment.reloadTemplates() reads provider warnings and displays them via flashError after adapter update.
String resource
resources/src/main/res/values/strings.xml
Added msg_template_warnings: "\n\nProject creation finished with warnings/errors. Open IDE Logs for details."
Template API & result types
templates-api/src/main/java/com/itsaky/androidide/templates/template.kt, templates-impl/src/main/java/com/itsaky/androidide/templates/impl/base/results.kt
ProjectTemplateRecipeResult interface gains val hasErrorsWarnings: Boolean. ProjectTemplateRecipeResultImpl constructor now accepts hasErrorsWarnings: Boolean = false and overrides the property.
Warning collection & execution handling
templates-impl/src/main/java/com/itsaky/androidide/templates/impl/TemplateProviderImpl.kt, templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt, templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt
TemplateProviderImpl adds a public warnings: MutableList<String> cleared on reload and passed to ZipTemplateReader.read. ZipTemplateReader.read accepts warnings and appends warning strings on per-template or archive failures. ZipRecipeExecutor tracks hasErrorsWarnings, introduces structured error/warn/info logging that sets the flag, and threads hasErrorsWarnings into ProjectTemplateRecipeResultImpl.

Sequence Diagrams

sequenceDiagram
    participant DF as TemplateDetailsFragment
    participant MA as MainActivity
    participant PHA as ProjectHandlerActivity
    participant TP as TemplateProviderImpl
    participant ZTR as ZipTemplateReader
    participant ZRE as ZipRecipeExecutor

    DF->>ZRE: execute(template)
    ZRE->>ZRE: process entries, log warn/error (sets hasErrorsWarnings)
    ZRE-->>DF: ProjectTemplateRecipeResultImpl(hasErrorsWarnings)
    DF->>MA: openProject(dir, project, hasTemplateIssues=hasErrorsWarnings)
    MA->>PHA: start Intent with HAS_TEMPLATE_ISSUES extra
    PHA->>PHA: onCreate checks HAS_TEMPLATE_ISSUES
    alt HAS_TEMPLATE_ISSUES == true
        PHA->>PHA: flashError(msg_template_warnings)
    end
    TP->>ZTR: read(zipFile, warnings)
    ZTR->>ZTR: append warnings on failures
    ZTR-->>TP: templates (warnings populated)
    TP->>TP: expose warnings to UI (TemplateListFragment)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • Daniel-ADFA
  • itsaky-adfa

Poem

🐰 I hopped through zips and recipes bright,
Collected warnings by lantern-light,
I flagged the project and gave it a shout—
"See the logs!" I whispered, nibbling a sprout. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix/ADFA-3380 template warnings' directly relates to the main objective of showing template warnings during generation.
Description check ✅ Passed The description 'Show detailed warnings and errors in IDE Logs tab during template generation' is directly related to the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ADFA-3380-template-warnings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt (1)

35-39: ⚠️ Potential issue | 🟠 Major

Report a missing ARCHIVE_JSON entry instead of silently returning.

Line 38 still returns emptyList() when the archive index is absent, so a malformed template ZIP bypasses the new warning/logging path and just looks like “no templates found.”

Proposed fix
-                val indexEntry = zip.getEntry(ARCHIVE_JSON) ?: return emptyList()
+                val indexEntry = zip.getEntry(ARCHIVE_JSON)
+                if (indexEntry == null) {
+                    warnings.add("Missing template index $ARCHIVE_JSON in archive $zipFile")
+                    log.error("Missing template index $ARCHIVE_JSON in archive $zipFile")
+                    return emptyList()
+                }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt`
around lines 35 - 39, The code in ZipTemplateReader (ZipTemplateReader.kt)
currently returns emptyList() when the ARCHIVE_JSON entry is missing, silently
hiding malformed template ZIPs; update the logic in the try block where
zip.getEntry(ARCHIVE_JSON) is checked so that instead of returning emptyList()
it reports the missing entry (e.g., throw a specific exception or call the
existing logger/error reporting path) with a clear message including the ZIP
file name and ARCHIVE_JSON, ensuring callers can distinguish a malformed archive
from "no templates found" (locate the check around zip.getEntry(ARCHIVE_JSON)
and replace the silent return with a logged/exceptional path consistent with the
module's error handling).
🧹 Nitpick comments (4)
templates-impl/src/main/java/com/itsaky/androidide/templates/impl/TemplateProviderImpl.kt (1)

47-47: Expose warnings as read-only API, not mutable state.

val warnings: MutableList<String> leaks internal mutability and creates tight coupling with consumers.

🔒 Proposed encapsulation
-    val warnings: MutableList<String> = mutableListOf()
+    private val warnings: MutableList<String> = mutableListOf()
+    val templateWarnings: List<String>
+        get() = warnings.toList()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/TemplateProviderImpl.kt`
at line 47, The public property warnings is declared as a MutableList and leaks
internal mutability; change TemplateProviderImpl to keep a private mutable
backing field (e.g., _warnings or backingWarnings) and expose a read-only
List<String> via a public val warnings: List<String> (or a getter returning the
backing list), and update any internal code that mutates warnings to use the
private backing field instead so consumers cannot modify internal state.
app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt (1)

403-430: Extract intent extra keys into shared constants.

"HAS_TEMPLATE_ISSUES" and "PROJECT_PATH" are string literals; centralizing them avoids key drift between launcher and receiver.

♻️ Proposed refactor
+companion object {
+    const val EXTRA_PROJECT_PATH = "PROJECT_PATH"
+    const val EXTRA_HAS_TEMPLATE_ISSUES = "HAS_TEMPLATE_ISSUES"
+}
...
-                putExtra("PROJECT_PATH", root.absolutePath)
+                putExtra(EXTRA_PROJECT_PATH, root.absolutePath)
                 if (hasTemplateIssues) {
-                    putExtra("HAS_TEMPLATE_ISSUES", true)
+                    putExtra(EXTRA_HAS_TEMPLATE_ISSUES, true)
                 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt` around
lines 403 - 430, The openProject function uses string literals "PROJECT_PATH"
and "HAS_TEMPLATE_ISSUES" for intent extras; extract these into shared constants
(e.g., add public const val PROJECT_PATH and HAS_TEMPLATE_ISSUES in
EditorActivityKt's companion object or a shared Constants object) and replace
the literal usages in openProject (Intent.apply putExtra calls) with the new
constants; also update any recipient code (EditorActivityKt reading intent
extras) to use the same constants so keys are centralized and type-safe.
templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt (1)

119-162: Narrow the new entry-processing catch blocks.

The added catch (e: Exception) handlers around template read/parse/evaluate/write/copy will also hide unrelated executor bugs behind warning logs. Limit each site to the expected PebbleException/I/O failures and let unexpected exceptions surface. Based on learnings: in Kotlin files across this project, prefer narrow exception handling over a broad catch (e: Exception); this aligns with fail-fast behavior during development.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt`
around lines 119 - 162, The broad catch-all Exception handlers in
ZipRecipeExecutor.kt around reading/parsing/evaluating/writing/copying template
entries should be narrowed: replace catch (e: Exception) blocks with specific
exceptions (e.g., IOException for file I/O operations, PebbleException for
pebble parsing/evaluation) and allow unexpected exceptions to propagate (or
rethrow) so they fail fast; specifically update the try around
pebbleEngine.getTemplate(content) to only catch PebbleException, the
template.evaluate(writer, identifiers) block to catch PebbleException, the
outFile.writeText(...) and zip.getInputStream(...)/input.copyTo(output) blocks
to catch IOException (or more specific java.io exceptions), and remove or
rethrow the outer catch (e: Exception) that currently swallows all errors in
processTemplate entry handling.
templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt (1)

113-121: Narrow these catch-all loaders.

Both new catch (e: Exception) blocks will also downgrade unexpected loader bugs to recoverable warnings. Catch the ZIP/JSON failures you actually expect here and let the rest fail fast. Based on learnings: in Kotlin files across this project, prefer narrow exception handling over a broad catch (e: Exception); this aligns with fail-fast behavior during development.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt`
around lines 113 - 121, The two broad catch-all handlers in ZipTemplateReader
(the blocks catching "Exception" around the per-entry template read that logs
"Failed to load template at ${templateRef.path}" and the outer zip read that
logs "Failed to read zip file $zipFile") should be narrowed: catch only the
expected I/O and parsing exceptions (e.g., IOException/ZipException for
archive/stream issues and JsonProcessingException/JsonParseException or
JSONException/kotlinx.serialization exceptions for JSON/template parsing) and
add the warning/log message there; any other unexpected exceptions should be
rethrown so they fail fast. Update the catch clauses in the method(s) in
ZipTemplateReader.kt that surround reading the zip and parsing template JSON
(the blocks referencing templateRef.path and zipFile) to handle these specific
exception types and keep the existing warnings/logging for those cases, letting
other exceptions propagate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/main/java/com/itsaky/androidide/fragments/TemplateListFragment.kt`:
- Around line 120-123: The cast of provider to TemplateProviderImpl is unsafe
and can throw ClassCastException; change the access to warnings to use a safe
cast or type check: obtain provider via ITemplateProvider.getInstance(reload =
true), then check if provider is TemplateProviderImpl (or use a safe cast with
"as?" equivalent) and read (TemplateProviderImpl).warnings only when available,
otherwise use a sensible fallback (e.g., empty warnings list) so getTemplates()
and the UI don't crash; update the code that references provider/warnings (the
provider variable, ITemplateProvider.getInstance and
TemplateProviderImpl.warnings) accordingly.

In `@resources/src/main/res/values/strings.xml`:
- Line 1019: Remove the leading newline characters from the string resource
named msg_template_warnings so the flash message doesn't start with blank lines;
update the value of msg_template_warnings to begin directly with "Project
creation finished with warnings/errors. Open IDE Logs for details." (keep the
rest of the text unchanged) to preserve readability.

In `@templates-api/src/main/java/com/itsaky/androidide/templates/template.kt`:
- Around line 61-63: The interface ProjectTemplateRecipeResult exposes an
abstract val hasErrorsWarnings which forces all implementers to immediately
provide an implementation; change it to provide a default getter (e.g. val
hasErrorsWarnings: Boolean get() = false) so the interface supplies a sensible
default and preserves API/binary compatibility for external implementers of
ProjectTemplateRecipeResult (which extends
TemplateRecipeResultWithData<ProjectTemplateData>).

In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt`:
- Around line 133-146: The current code always calls
outFile.writeText(writer.toString(), Charsets.UTF_8) even when
template.evaluate(...) failed and only logged an error; change the flow so the
file is not written when evaluation throws: for example, in the evaluate block
(where template.evaluate(writer, identifiers) is called and
PebbleException/Exception are caught) stop further processing on error (either
rethrow, return/continue the enclosing loop, or set a success flag) and only
call outFile.writeText(...) if evaluation succeeded; refer to template.evaluate,
the writer StringWriter, the caught PebbleException/Exception handlers,
entry.name and outFile.writeText to locate and implement this control-flow fix.

---

Outside diff comments:
In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt`:
- Around line 35-39: The code in ZipTemplateReader (ZipTemplateReader.kt)
currently returns emptyList() when the ARCHIVE_JSON entry is missing, silently
hiding malformed template ZIPs; update the logic in the try block where
zip.getEntry(ARCHIVE_JSON) is checked so that instead of returning emptyList()
it reports the missing entry (e.g., throw a specific exception or call the
existing logger/error reporting path) with a clear message including the ZIP
file name and ARCHIVE_JSON, ensuring callers can distinguish a malformed archive
from "no templates found" (locate the check around zip.getEntry(ARCHIVE_JSON)
and replace the silent return with a logged/exceptional path consistent with the
module's error handling).

---

Nitpick comments:
In `@app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt`:
- Around line 403-430: The openProject function uses string literals
"PROJECT_PATH" and "HAS_TEMPLATE_ISSUES" for intent extras; extract these into
shared constants (e.g., add public const val PROJECT_PATH and
HAS_TEMPLATE_ISSUES in EditorActivityKt's companion object or a shared Constants
object) and replace the literal usages in openProject (Intent.apply putExtra
calls) with the new constants; also update any recipient code (EditorActivityKt
reading intent extras) to use the same constants so keys are centralized and
type-safe.

In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/TemplateProviderImpl.kt`:
- Line 47: The public property warnings is declared as a MutableList and leaks
internal mutability; change TemplateProviderImpl to keep a private mutable
backing field (e.g., _warnings or backingWarnings) and expose a read-only
List<String> via a public val warnings: List<String> (or a getter returning the
backing list), and update any internal code that mutates warnings to use the
private backing field instead so consumers cannot modify internal state.

In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt`:
- Around line 119-162: The broad catch-all Exception handlers in
ZipRecipeExecutor.kt around reading/parsing/evaluating/writing/copying template
entries should be narrowed: replace catch (e: Exception) blocks with specific
exceptions (e.g., IOException for file I/O operations, PebbleException for
pebble parsing/evaluation) and allow unexpected exceptions to propagate (or
rethrow) so they fail fast; specifically update the try around
pebbleEngine.getTemplate(content) to only catch PebbleException, the
template.evaluate(writer, identifiers) block to catch PebbleException, the
outFile.writeText(...) and zip.getInputStream(...)/input.copyTo(output) blocks
to catch IOException (or more specific java.io exceptions), and remove or
rethrow the outer catch (e: Exception) that currently swallows all errors in
processTemplate entry handling.

In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt`:
- Around line 113-121: The two broad catch-all handlers in ZipTemplateReader
(the blocks catching "Exception" around the per-entry template read that logs
"Failed to load template at ${templateRef.path}" and the outer zip read that
logs "Failed to read zip file $zipFile") should be narrowed: catch only the
expected I/O and parsing exceptions (e.g., IOException/ZipException for
archive/stream issues and JsonProcessingException/JsonParseException or
JSONException/kotlinx.serialization exceptions for JSON/template parsing) and
add the warning/log message there; any other unexpected exceptions should be
rethrown so they fail fast. Update the catch clauses in the method(s) in
ZipTemplateReader.kt that surround reading the zip and parsing template JSON
(the blocks referencing templateRef.path and zipFile) to handle these specific
exception types and keep the existing warnings/logging for those cases, letting
other exceptions propagate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8e593f73-abaa-4c81-ae87-1ebe5211b9cc

📥 Commits

Reviewing files that changed from the base of the PR and between a59a64a and 35a3b67.

📒 Files selected for processing (10)
  • app/src/main/java/com/itsaky/androidide/activities/MainActivity.kt
  • app/src/main/java/com/itsaky/androidide/activities/editor/ProjectHandlerActivity.kt
  • app/src/main/java/com/itsaky/androidide/fragments/TemplateDetailsFragment.kt
  • app/src/main/java/com/itsaky/androidide/fragments/TemplateListFragment.kt
  • resources/src/main/res/values/strings.xml
  • templates-api/src/main/java/com/itsaky/androidide/templates/template.kt
  • templates-impl/src/main/java/com/itsaky/androidide/templates/impl/TemplateProviderImpl.kt
  • templates-impl/src/main/java/com/itsaky/androidide/templates/impl/base/results.kt
  • templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt
  • templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt (1)

293-311: ⚠️ Potential issue | 🟠 Major

Cross-platform bug: ZIP entry paths use /, not File.separator.

ZIP archives always use forward slash (/) as the path separator, regardless of the operating system. On Windows, File.separator is \, so entryName.split(File.separator) will fail to split the entry name correctly.

Note that lines 85-87 already correctly use / for ZIP entry path checks. The joining at line 310 with File.separator is appropriate for constructing file system paths, but the split on input needs to use /.

Proposed fix
     private fun filterAndNormalizeZipEntry(
         entryName: String,
         flags: Map<String, Boolean>
     ): String? {
-        val parts = entryName.split(File.separator).filter { it.isNotEmpty() }
+        val parts = entryName.split("/").filter { it.isNotEmpty() }
         if (parts.isEmpty()) return null

         val normalizedParts = mutableListOf<String>()

         for (part in parts) {
             when (flags[part]) {
                 null -> normalizedParts.add(part)
                 true -> { }
                 false -> return null
             }
         }

         return normalizedParts.joinToString(File.separator)
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt`
around lines 293 - 311, The split logic in filterAndNormalizeZipEntry is
incorrect for ZIP entries: change entryName.split(File.separator) to
entryName.split("/") (ZIP uses forward slashes always), keep the existing filter
{ it.isNotEmpty() } and continue to join with File.separator when returning the
normalized filesystem path; update only the split call in the
filterAndNormalizeZipEntry function so path checks and normalization work
cross-platform.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt`:
- Around line 293-311: The split logic in filterAndNormalizeZipEntry is
incorrect for ZIP entries: change entryName.split(File.separator) to
entryName.split("/") (ZIP uses forward slashes always), keep the existing filter
{ it.isNotEmpty() } and continue to join with File.separator when returning the
normalized filesystem path; update only the split call in the
filterAndNormalizeZipEntry function so path checks and normalization work
cross-platform.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 086eb611-209d-4a14-996b-10ca806be4ca

📥 Commits

Reviewing files that changed from the base of the PR and between 35a3b67 and af4458d.

📒 Files selected for processing (3)
  • app/src/main/java/com/itsaky/androidide/fragments/TemplateListFragment.kt
  • templates-api/src/main/java/com/itsaky/androidide/templates/template.kt
  • templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/main/java/com/itsaky/androidide/fragments/TemplateListFragment.kt

@davidschachterADFA davidschachterADFA merged commit ec0a78f into stage Apr 1, 2026
2 checks passed
@davidschachterADFA davidschachterADFA deleted the fix/ADFA-3380-template-warnings branch April 1, 2026 23:21
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.

2 participants