Feat/optional project scoping#193
Conversation
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. |
_SpecificWorkItem.query() and TestRun.search() unconditionally append "AND project.id:<default_project>" to every query, so there is no way to search the whole Polarion instance even though the underlying Tracker.queryWorkItems / TestManagement.searchTestRuns services support it. The other search wrappers (base _WorkItem.query(), Document.query(), Plan.search()) never scope to a project and leave the query to the caller, so these two methods are the only ones that need an opt-out. Add an explicit all_projects keyword argument (default False) to both methods. When set, the project.id clause is simply not appended and the query runs instance-wide; combining it with project_id raises PyleroLibException instead of silently preferring one of them. Nothing else changes: default_project remains required, custom-field initialization still uses the default project, and all existing calls behave exactly as before. Document the scoping behaviour in the README. Assisted-by: Artificial Intelligence
An absent default_project key (with no POLARION_PROJECT env var) made Configuration.__init__ crash with an unhandled configparser NoOptionError, and an empty value slipped through validation only to break later with cryptic SOAP/query errors (e.g. a dangling "AND project.id:" clause). Disallow both explicitly: Configuration now raises PyleroLibException naming the config files and env var to set, and pointing at all_projects=True as the supported way to query across projects. The default_project term in the pre-existing url/credentials check is dropped because it can no longer be reached, and that check's message is corrected accordingly. Add configuration_test.py covering the set/empty/missing/env-var default_project cases and the url/credentials check; it runs offline without a Polarion instance (nose2 -s src/unit_tests configuration_test). Assisted-by: Artificial Intelligence
d16bb97 to
99c2b22
Compare
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.