OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: Role.value AttributeError after Role refactored from Enum to str subclass"

Open hhspiny opened this issue 5 months ago • 1 comments

Bug Description

Not a programmer, I noticed the problem that memory_store tool in openclaw (plugin 2026.6.18) does not work and asked AI to created the report below.

Role was refactored from an Enum to a str subclass, but 12 references to .value on Role objects were not cleaned up. This causes AttributeError: 'Role' object has no attribute 'value' in the memory extraction pipeline (triggered by memory_store), as well as in content_write, summarizer, resource_service, fs_service, watch_scheduler, and semantic_processor.

The Role class definition (in openviking/server/identity.py):

class Role(str): """Role type — supports built-in roles and custom plugin-defined roles.""" ROOT = "root" ADMIN = "admin" USER = "user" Since Role is now a str subclass, Role.USER returns the plain string "user", and strings do not have a .value attribute.

Steps to Reproduce

  1. Start an OpenClaw session with the OpenViking plugin (v2026.6.18) connected to OpenViking server v0.4.4
  2. Call memory_store to write a memory
  3. The extraction pipeline triggers session archiving
  4. Observe error: "Memory extraction failed for session memory-store-...: 'Role' object has no attribute 'value'"

Expected Behavior

Memory extraction should complete successfully and write memories to OpenViking.

Actual Behavior

Memory extraction fails silently. The memory text is written to the OpenViking session but the extraction (which reads it back to create a memory index entry) crashes with AttributeError.

Minimal Reproducible Example


Error Logs

Memory extraction failed for session memory-store-1782237102898-1kefsa: 'Role' object has no attribute 'value'

OpenViking Version

0.4.4

Python Version

3.12.3

Operating System

Linux

Model Backend

Other

Additional Context

Root cause: Role was an Enum (where .value is valid) and was changed to a str subclass. All .value accesses need to be replaced with the attribute directly or wrapped in str().

Affected locations (12 occurrences across 7 files):

File Line(s) Pattern Fix
openviking/session/session.py 1329 self.ctx.role.value str(self.ctx.role)
openviking/storage/content_write.py 469 ctx.role.value str(ctx.role)
openviking/utils/summarizer.py 121 ctx.role.value str(ctx.role)
openviking/storage/queuefs/semantic_processor.py 174 {r.value for r in Role} {str(r) for r in Role} (also needs fix for iterating over class — Role is not iterable)
openviking/resource/watch_scheduler.py 242, 315 Role.USER.value Role.USER
openviking/service/resource_service.py 954, 967, 988, 1016, 1023 ctx.role.value str(ctx.role)
openviking/service/fs_service.py 334 ctx.role.value str(ctx.role)

The simplest fix for each .value access is to use str(obj) or just the attribute directly (since Role is already a string). The semantic_processor.py case also needs Role to be iterable — either making Role iterable via metaclass or restructuring that logic to check against {Role.ROOT, Role.ADMIN, Role.USER}.

hhspiny avatar Jun 23 '26 18:06 hhspiny

you cant upgrade 0.4.5

qin-ctx avatar Jun 25 '26 08:06 qin-ctx