Lizmap Web Client Bug Boolean Fields To Checkboxes Resulting In Null Values

by StackCamp Team 76 views

Hey guys! Today, we're diving deep into a peculiar bug in the Lizmap Web Client that many of you might have encountered. It's all about boolean fields, checkboxes, and how they sometimes lead to null values. If you've been scratching your head over this issue, you're in the right place. Let's break it down and see what's going on.

Understanding the Bug

So, what's the deal? Since the installation of the 3.9.2 version of LWC, some users have noticed that boolean values are systematically updated to NULL when saving a new point or changing an old one, especially in projects where the default value of a boolean field has been altered. This issue transforms boolean fields into checkboxes, which then, unexpectedly, result in null values. This can be super frustrating, especially when you're relying on accurate data. It's like you're trying to keep things in order, and suddenly, everything's turning into a big question mark!

One user, @meyerlor, flagged this problem way back in Issue 6063, so it's not exactly a new issue. But let's get into the nitty-gritty so you can figure out if you're facing the same problem and how to tackle it. This issue not only affects new data entries but also corrupts existing boolean values upon modification, making data management a real headache. The unexpected behavior can lead to significant data integrity issues, requiring careful attention and debugging.

The Impact of Null Values

Null values in your dataset can wreak havoc if not properly addressed. They can skew analyses, produce incorrect reports, and lead to flawed decision-making. Imagine you're tracking whether a feature has been inspected, and the boolean field keeps turning into null – you'd lose track of what's been checked and what hasn't! This is why understanding and resolving this bug is crucial for maintaining the reliability of your spatial data and applications.

Steps to Reproduce the Issue

Okay, let's get practical. How can you tell if you're dealing with this bug? Here’s a step-by-step guide to reproduce the issue:

  1. Open a form on LWC with at least one boolean field.

    • The first step is to access a form within Lizmap Web Client that contains at least one field designed to store boolean data (true/false values). This is where the problem originates, so it's the natural starting point for investigation.
  2. Observe the boolean fields.

    • Take a look at those boolean fields. You might notice they all appear checked, even if there are false values saved in the database. It’s like seeing a bunch of “yes” answers when you know some should be “no.” This visual misrepresentation is your first clue that something's amiss.
    • This initial visual cue is critical because it indicates a discrepancy between the stored data and its representation in the user interface. It's a clear sign that the boolean fields are not being accurately displayed.
  3. Change nothing or anything, a boolean field or another one.

    • Now, try making a minor change. It doesn't even have to be in the boolean field itself. Tweak something else in the form, or even leave everything as is. The goal here is to trigger the save action.
    • The act of saving, even without changing the boolean field directly, is what triggers the bug. This suggests that the issue lies within the save process and how it handles boolean data specifically.
  4. Save it.

    • Hit that save button! This is where the magic (or rather, the bug) happens.
  5. Check the results.

    • After saving, you'll find that all boolean fields have been modified with null values. Yep, they've all gone missing in action. This is the heart of the problem, where the expected true or false values are replaced with null, compromising the integrity of your data.
    • The conversion to null values is a significant data loss event, particularly problematic in applications relying on accurate boolean flags for decision-making. This step confirms the bug's presence and its impact on the data.

By following these steps, you can reliably reproduce the bug and confirm if it's affecting your setup. Once you've verified the issue, you can start looking at potential solutions or workarounds.

Log Analysis

When you dig into the logs, you’ll see that all the boolean fields are being modified by mistake. This is a crucial clue for developers, pointing towards a potential issue in the update logic or data handling within the Lizmap Web Client. Log analysis is essential for understanding the underlying cause of the problem and devising an effective fix.

The Backstory: Versions and Modifications

Here’s some context that might ring a bell for some of you. The QGIS project was originally in a 3.8.3 LWC version without any hiccups. However, after modifying it to be compatible with the 3.9.2 LWC version, and changing a default value of one of the boolean fields, this issue popped up shortly after. So, if you've recently upgraded and tweaked boolean field defaults, you might be in the same boat. This historical context helps narrow down the potential causes and timing of the bug's introduction.

The issue seems to be triggered by a combination of factors, including the specific version of LWC (3.9.2), the modification of default boolean values, and the subsequent saving of data. Understanding these triggers is crucial for developing a targeted solution and preventing future occurrences.

Technical Details

Let's get a bit more specific. Here are the versions and configurations that are in play when this bug occurs:

  • Lizmap Web Client: 3.9.2 - commit fd848d56b (https://github.com/3liz/lizmap-web-client/commit/fd848d56b)
  • Lizmap plugin: 4.5.4
  • QGIS Desktop: 3.40.7
  • Lizmap.com: Yes
  • QGIS Server: 3.40.11
  • Py-QGIS-Server: 1.9.6
  • QGIS Server plugin atlasprint: 3.4.3
  • QGIS Server plugin cadastre: 2.2.1
  • QGIS Server plugin lizmap_server: 2.14.0
  • QGIS Server plugin wfsOutputExtension: 1.8.3

These version numbers are like the ingredients in a recipe – you need the right combination to reproduce the bug. If you're running similar versions, you're more likely to encounter this issue. The detailed version information allows developers to pinpoint the exact codebase where the bug might reside, facilitating more efficient debugging and patching efforts.

Lizmap Web Client Modules

Here’s a list of Lizmap Web Client modules that are part of this setup:

  • cadastre: 2.1.6
  • saas: 1.7.7
  • webdav: 1.2.1

Safeguards

And here are the safeguards in place:

  • Mode: normal
  • Allow parent folder: yes
  • Number of parent: 2 folder(s)
  • Prevent other drive: yes
  • Prevent PG service: yes
  • Prevent PG Auth DB: yes
  • Force PG user&pass: yes
  • Prevent ECW: yes

These safeguards are designed to protect the system, but they don't seem to prevent this particular bug. Understanding the safeguard configuration is important for assessing the overall security posture and identifying any potential conflicts or interactions with the bug.

Plugin Check

It’s essential to ensure that the Lizmap QGIS desktop plugin has been set up correctly. This step is crucial because misconfigurations in the plugin can often lead to unexpected issues in the web client. Checking the plugin configuration is a standard troubleshooting step to rule out common setup-related problems.

  • [x] I have done the step just before in the Lizmap QGIS desktop plugin before opening this ticket. Otherwise, my ticket is not considered valid and might get closed.

Operating Environment

Knowing the operating environment is key to understanding the context of the bug. This issue was observed on:

  • Operating system: Windows 11 on PC and Lizmap server for our instance
  • Browsers: Firefox
  • Browsers version: 143.0.4

This information helps developers replicate the environment where the bug occurs, increasing the chances of identifying and fixing it. Different operating systems and browsers can sometimes interact differently with web applications, making environmental details crucial for debugging.

Diving Deeper: Relevant Log Output

Unfortunately, there's no specific log output provided in the original report. However, when troubleshooting, log outputs are your best friends. They often contain error messages, warnings, or other clues that can point you directly to the source of the problem. If you're experiencing this issue, make sure to check your server logs for any relevant messages. Analyzing log outputs can provide valuable insights into the sequence of events leading up to the bug, helping developers trace the root cause and implement a fix.

Wrapping Up

So, there you have it! The boolean fields turning into checkboxes and resulting in null values bug in Lizmap Web Client. It’s a tricky one, but with the right information, you can identify it, reproduce it, and hopefully, find a solution or workaround. Keep an eye on those boolean fields, and happy mapping!

Understanding this bug not only helps in troubleshooting but also highlights the importance of thorough testing and version control in software development. By documenting and sharing such issues, the community can contribute to a more robust and reliable Lizmap Web Client.