Project

General

Custom queries

Profile

Actions

Bug #26088

open

NPE in archive generation

Added by François ARMAND 22 days ago. Updated 7 days ago.

Status:
Pending release
Priority:
1 (highest)
Category:
Web - Compliance & node report
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Name check:
To do
Fix check:
Checked
Regression:
No

Description

2024-12-18 09:59:17+0000 INFO  net.liftweb.http.LiftServlet - Request for /rudder/lift/ajax/F819842088788PLFPXD-20/ failed Cannot invoke "String.endsWith(String)" because the return value of "com.normation.rudder.git.ZipUtils$Zippable.path()" is null
zio.FiberFailure: Cannot invoke "String.endsWith(String)" because the return value of "com.normation.rudder.git.ZipUtils$Zippable.path()" is null
    at com.normation.rudder.git.ZipUtils$.$anonfun$zip$11(ZipUtils.scala:149)
    at zio.ZIO$.$anonfun$foreachDiscard$3(ZIO.scala:3411)
    at com.normation.rudder.git.ZipUtils.zip(ZipUtils.scala:146)
    at com.normation.rudder.git.ZipUtils.zip(ZipUtils.scala:143)
    at com.normation.rudder.git.GitFindUtils.getZip(GitFindUtils.scala:201)
    at com.normation.rudder.git.GitFindUtils.getZip(GitFindUtils.scala:200)
    at com.normation.rudder.rest.lift.SystemApiService11.getZip(SystemApi.scala:847)
    at com.normation.rudder.rest.lift.SystemApiService11.getZip(SystemApi.scala:840)
    at com.normation.rudder.rest.lift.SystemApiService11.getZip(SystemApi.scala:853)
    at com.normation.rudder.rest.lift.SystemApiService11.getZip(SystemApi.scala:854)
    at com.normation.zio.ZioRuntime.unsafeRun(ZioCommons.scala:445)
Caused by: java.lang.NullPointerException: Cannot invoke "String.endsWith(String)" because the return value of "com.normation.rudder.git.ZipUtils$Zippable.path()" is null

Zippable.path can be null, because java. It must be checked for or encapsulated in an IOResult.attempt

      ZIO.foreachDiscard(unique) { x =>
        val name = x.useContent match {
          case None     =>
            if (x.path.endsWith("/")) {
              x.path
            } else {
              x.path + "/" 
            }
          case Some(is) =>
            if (x.path.endsWith("/")) {
              x.path.substring(0, x.path.size - 1)
            } else {
              x.path
            }
        }
        IOResult.attempt(zout.putNextEntry(new ZipEntry(name))) *> (
          x.useContent match {
            case None    => ().succeed
            case Some(x) => x(addToZout)
          }
        )
      }


Files

clipboard-202412181136-ufzl1.png (26.2 KB) clipboard-202412181136-ufzl1.png Elaad FURREEDAN, 2024-12-18 11:36
Actions #1

Updated by François ARMAND 22 days ago

  • Priority changed from N/A to To review
Actions #2

Updated by Elaad FURREEDAN 22 days ago

Can be reproduced by downloading global archive zip from the UI

Actions #4

Updated by François ARMAND 21 days ago

  • Priority changed from To review to 1 (highest)
Actions #5

Updated by François ARMAND 21 days ago

  • Assignee set to François ARMAND
Actions #6

Updated by François ARMAND 21 days ago

  • Status changed from New to In progress
Actions #7

Updated by François ARMAND 21 days ago

So, the culprit is:

2024-12-19 15:31:00+0000 INFO  net.liftweb.http.LiftServlet - Request for /rudder/lift/ajax/F16475049919103KXMAV-00/ failed A zippable can not be created with an 'null' path (useContent is empty)
zio.FiberFailure: A zippable can not be created with an 'null' path (useContent is empty)
    at com.normation.rudder.git.ZipUtils$Zippable.<init>(ZipUtils.scala:66)
    at com.normation.rudder.git.ZipUtils$Zippable$.make(ZipUtils.scala:76)
    at com.normation.rudder.git.GitFindUtils$.$anonfun$getZip$2(GitFindUtils.scala:199)
    at scala.collection.immutable.List.map(List.scala:246)
    at scala.collection.immutable.List.map(List.scala:79)
    at com.normation.rudder.git.GitFindUtils$.$anonfun$getZip$1(GitFindUtils.scala:199)
    at zio.ZIO.$anonfun$map$2(ZIO.scala:960)
    at com.normation.rudder.git.GitFindUtils.getZip(GitFindUtils.scala:198)
    at com.normation.rudder.rest.lift.SystemApiService11.getZip(SystemApi.scala:847)
Actions #8

Updated by François ARMAND 21 days ago

We have a `file.getParent` that can be null and we don't check for it.

Actions #9

Updated by François ARMAND 21 days ago

  • Status changed from In progress to Pending technical review
  • Assignee changed from François ARMAND to Clark ANDRIANASOLO
  • Pull Request set to https://github.com/Normation/rudder/pull/6098
Actions #10

Updated by Anonymous 20 days ago

  • Status changed from Pending technical review to Pending release
Actions #11

Updated by François ARMAND 7 days ago

  • Fix check changed from To do to Checked

Checked on snapshot 8.1 with a build from 2025-01-02T00:52:19Z

Actions

Also available in: Atom PDF