Feat/optional project scoping#193
Conversation
When default_project is intentionally empty, pylero now operates
in global-scope mode without requiring a project to be set:
- _SpecificWorkItem.query(): project filter is only appended when a
project is actually resolved; pass project_id="" to bypass even a
configured default_project and get instance-wide results.
- TestRun.search(): same treatment — project filter and custom-field
initialisation are skipped when no project is resolved.
- _get_enum_options(): normalise "" to None so Polarion treats the
call as instance-wide (null project), avoiding URI validation errors.
- get_custom_fields(): early-return when project_id is falsy to avoid
an invalid getDefinedCustomFieldTypes("", …) SOAP call.
- Module-level workitem-type enum fetch and _SpecificWorkItem subclass
creation are guarded with `if cfg.proj:` so they are skipped entirely
in global-scope mode.
Assisted-by: Artificial Intelligence
476b85e to
d16bb97
Compare
|
sry, I'm a bit confused about the issue? if we were accepting empty string for default_project then that's a bug to be fixed disallowing empty string but not workaround it and anything that's touching the cfg at basepolarion needs a good testing. AI code is fine but it should be reviewed by the author before posting, on a quick glance it's a bit troublesome to review rest of the code when I see a new |
the objective is to be able to execute query statements against the global scope. Without these changes queries would fall back to be executed against „default_project“ if no other project was explicitly specified. Working around this limitation by specifiying an empty string as default _project would lead to a crash either in pylero or the Server side.
Makes sense.
Fair enough, my apologies. I’ll manually review and ping again. |
Disclaimer
This contribution was created AI assisted. Feel free to reject it right away if it violates your policies.
Problem
PyleroConfig.__init__requiresdefault_projectto be set — either via thePOLARION_PROJECTenvironment variable or as a key in~/.pylero. If neither is present,config.get()on line 78 raises an unhandledconfigparser.NoOptionErrorand the module fails to initialize entirely.The only valid workaround was to set
default_project=(empty string) in~/.pylero. But the old search methods treated an emptydefault_projectas falsy and fell back to it unconditionally viaor, producing a broken Lucene fragment (AND project.id:) that would be rejected by Polarion.Fix
TestRun.search()and_SpecificWorkItem.query()now distinguishNonefrom""using an explicit identity check:None→ falls back todefault_project(unchanged for users with a project configured).""→ project filter is omitted, enabling cross-project queries. This makesdefault_project=in~/.pyleroa valid, well-behaved configuration.Backwards compatibility
Fully backwards-compatible. Any caller passing a non-empty
project_idor relying on a non-emptydefault_projectsees identical behaviour.