Skip to content

Match the kb folder as a path component in _load_path#2165

Closed
winklemad wants to merge 1 commit into
NVIDIA-NeMo:developfrom
winklemad:fix/load-path-kb-folder-match
Closed

Match the kb folder as a path component in _load_path#2165
winklemad wants to merge 1 commit into
NVIDIA-NeMo:developfrom
winklemad:fix/load-path-kb-folder-match

Conversation

@winklemad

Copy link
Copy Markdown

Description

_load_path collects knowledge-base documents by checking rel_path.startswith("kb"). That matches on the name prefix, not the kb/ folder, so any config file or folder whose name merely starts with "kb" is misclassified as a (usually empty) knowledge-base doc and silently dropped:

  • kbsettings.yml at the config root → treated as a doc; since it isn't .md, its YAML is never parsed and the config is lost.
  • a subfolder such as kbase/ → its .yml config and any .co flows are dropped (the .co is never appended to colang_files).

Meanwhile a genuine kb/doc.md loads fine. The code's own comment already states the intent — "a file in the kb folder".

>>> # a config dir containing kbsettings.yml (sample_conversation: "hi") and kbase/greeting.co
>>> raw_config, colang_files = _load_path(config_dir)
>>> raw_config.get("sample_conversation"), colang_files
(None, [])          # both silently dropped

Fix

Match the kb folder as a path component (kb + os.sep) rather than a name prefix, so only files actually inside kb/ are collected as docs. Genuine kb/ documents are unaffected.

Test Plan

Added test_load_path_kb_prefixed_names_are_not_dropped to tests/test_config_loading.py: a tmp_path config directory with kbsettings.yml, a kbase/ subfolder containing a .co flow, and a genuine kb/doc.md. It asserts the kb-prefixed config file is parsed, the kb-prefixed .co is registered in colang_files, and the real kb/ doc is still collected. Fails on develop, passes with the fix.

$ pytest tests/test_config_loading.py tests/test_railsignore.py tests/test_combine_configs.py tests/test_config_validation.py tests/rails/llm/test_config.py
32 passed

$ ruff check nemoguardrails/rails/llm/config.py tests/test_config_loading.py
All checks passed!
$ ruff format --check nemoguardrails/rails/llm/config.py tests/test_config_loading.py
2 files already formatted

No linked issue — found by reading the code.

@github-actions github-actions Bot added status: needs triage New issues that have not yet been reviewed or categorized. size: S needs: signing labels Jul 11, 2026
@winklemad
winklemad force-pushed the fix/load-path-kb-folder-match branch 2 times, most recently from 42b7dcf to c1b1976 Compare July 11, 2026 08:19
_load_path classified any config file or folder whose relative path starts
with the letters "kb" as a knowledge-base document. A file named e.g.
kbsettings.yml, or a subfolder like kbase/, was therefore treated as an
(empty) kb doc and silently dropped -- its YAML config and any .co flows
never loaded. Match the kb folder as a path component (kb + os.sep) so only
files actually inside kb/ are collected as docs.

Signed-off-by: winklemad <winklemad@outlook.com>
@winklemad
winklemad force-pushed the fix/load-path-kb-folder-match branch from c1b1976 to 42f5645 Compare July 11, 2026 19:23
@Pouyanpi Pouyanpi added the status: contribution workflow violation PR does not meet the required workflow in CONTRIBUTING.md. label Jul 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@winklemad, this PR is being closed because it was opened before completing the required contribution workflow. Every PR must link to a triaged issue assigned to the PR author; this PR does not link to such an issue.

The PR description must also use our current template, including the Related Issue, Verification, and AI Assistance sections. If AI tools substantially assisted with the contribution, disclose the tool and extent of assistance. The human contributor must review, verify, understand, and take responsibility for every submitted change. If no AI tools were used, select that option in the template.

Before submitting another PR:

  1. Search for an existing issue or manually open one using the appropriate issue template.
  2. Wait for a maintainer to triage the issue and assign it to you.
  3. After assignment, open a new PR from develop using the complete PR template, a Conventional Commit-style title, and the documented validation commands.

Please do not reopen this PR. You’re welcome to submit a new one after completing the workflow.

See CONTRIBUTING.md and AI_POLICY.md.

@github-actions github-actions Bot closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S status: contribution workflow violation PR does not meet the required workflow in CONTRIBUTING.md. status: needs triage New issues that have not yet been reviewed or categorized.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants