kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Validate --port, boolean environment variables and KOLIBRI_HOME

Open rtibbles opened this issue 2 weeks ago • 3 comments

🙂 Looking for an issue? Welcome! This issue is open for contribution. If this is the first time you’re requesting an issue, please:

  • Read Contributing guidelines carefully. Pay extra attention to Using generative AI. Pull requests and comments that don’t follow the guidelines won’t be answered.
  • Confirm that you’ve read the guidelines in your comment.

Overview

Three startup inputs aren't validated: the --port options, boolean environment variables and KOLIBRI_HOME. Bad values crash with a traceback, leave a pid file that breaks later commands, or are silently read the opposite way.

Complexity: Low Target branch: develop

Context

On develop at fe298f5449:

  • kolibri start --port 70000 (or -1) raises OverflowError: connect(): port must be 0-65535 and leaves server.pid with that port. After that, kolibri status and kolibri stop raise the same error until the file is deleted by hand. cli.py#L237-L247 declares the port as a plain int. Ports in options.ini are range-checked.
  • Boolean environment variables are true for any non-empty value. KOLIBRI_DISABLE_REQUEST_LOGGING=False disables request logging, and KOLIBRI_NO_FILE_BASED_LOGGING=0 disables file logging. logger.py#L16-L17, conf.py#L29, env.py#L216.
  • KOLIBRI_HOME with a missing parent raises RuntimeError, and pointing at a file raises NotADirectoryError, both with tracebacks. KOLIBRI_HOME= (empty) silently uses the current directory as the home. conf.py#L28-L43.

The Change

  • --port and --zip-port should be range-checked like ports in options.ini.
  • Boolean environment variables should be parsed the way boolean options are.
  • KOLIBRI_HOME should be checked before anything is created in it.

Acceptance Criteria

  • [ ] --port and --zip-port outside 1-65535 exit with an error message and write no pid file.
  • [ ] Boolean environment variables read False, false, 0 and no as false.
  • [ ] Each KOLIBRI_HOME case under Context exits with an error message and no traceback.

AI usage

I had Claude Code sweep Kolibri's command-line tools and configuration handling for crashes on bad input and reproduce each one. I chose the grouping. Claude Code drafted the issue.

rtibbles avatar Nov 15 '26 20:11 rtibbles

Hi! 👋

This issue is available for contribution and supports self-assignment. Here's how to get started:

  • Comment /assign to assign yourself to this issue
  • You can have up to 2 issues assigned at a time across all community repos
  • Dropping an issue has a 7-day cooldown before the slot opens up
  • Link your pull request to this issue when you submit it

📖 Read the Contributing guidelines before starting.

Are you preparing for Google Summer of Code? See our GSoC guidelines.

learning-equality-bot avatar Nov 15 '26 21:11 learning-equality-bot

/assign

NethmikaKekuu avatar Nov 16 '26 01:11 NethmikaKekuu

Hi! 👋

You've been assigned to this issue. Here's what to do next:

  • Read the issue description carefully and make sure you understand the requirements
  • Link your pull request to this issue when you submit it
  • If you can no longer work on this, unassign yourself so others can pick it up

Good luck! 😊

Are you preparing for Google Summer of Code? See our GSoC guidelines.

learning-equality-bot avatar Nov 16 '26 01:11 learning-equality-bot