Repository navigation
Read GLPI 12's empty SLA/OLA reference arrays as none (0.6.9) - #48
Merged
Merged
Conversation
…ads work against a GLPI 12 server
GLPI 12.0.1 sends `ola_ttr` and `ola_tto` as `[]` on every ticket without an OLA. Its own v2.3 contract, like GLPI 11, declares a nullable `{"id", "name"}` object there. `GetTicket` typed both fields `IdNameRef | None` and refused the array. Every `get_ticket`, and every search that returns a ticket without an OLA, therefore raised `ValidationError` against GLPI 12.
`ola_ttr`, `ola_tto` and `ola_level_ttr` now go through a before-validator that turns an empty list into `None` and passes every other value on unchanged. An OLA object and `null` read as before. The SLA fields are untouched: GLPI 12 still sends them as an object or `null`.
Measured against a GLPI 12.0.1 server:
- Every ticket read came back with `ola_ttr: []` and `ola_tto: []`, including tickets that carry an SLA.
- An RSQL filter on `ola_ttr.id` answers HTTP 500, so a populated OLA's shape on GLPI 12 could not be observed, and this change makes no assumption about it.
- A saved GLPI 12 ticket payload now validates unchanged.
The new test fails on the old model and passes with the fix. The version moves to 0.6.9.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #48 +/- ##
=======================================
Coverage 98.06% 98.06%
=======================================
Files 94 94
Lines 3719 3726 +7
=======================================
+ Hits 3647 3654 +7
Misses 72 72 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…cket, not only the OLA ones On GLPI 12.0.1 only `ola_ttr` and `ola_tto` were seen as `[]`. The SLA references (`sla_ttr`, `sla_tto`, `sla_level_ttr`) use the same reference shape, so they now read through the same before-validator, and the same quirk on any of them cannot fail a ticket read. The alias `_OlaRef` is renamed `_LevelAgreementRef`. The tests are parametrised over all six fields: - `[]` reads as `None`. - An object reads as before. - `null` reads as before. - A GLPI 12 ticket shape with an SLA and no OLA reads correctly. Reverting `sla_ttr` alone to plain `IdNameRef | None` fails exactly its own `[]` case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GLPI 12.0.1 sends
ola_ttrandola_ttoas an empty array,[], on every ticket that has no OLA. Its own v2.3 OpenAPI contract, like GLPI 11, declares a nullable{"id", "name"}object for both fields.GetTickettypes these fieldsIdNameRef | None, so it refuses the array. Against a GLPI 12 server,get_ticket, and every search that returns such a ticket, raisesValidationError.Change
GetTicketgo through one before-validator that reads an empty list asNone:sla_ttr,sla_tto,sla_level_ttr,ola_ttr,ola_ttoandola_level_ttr.nullread as before.[]. They share the reference shape, so the same quirk on any of them can't fail a ticket read.Evidence
Measured against a GLPI 12.0.1 server:
ola_ttr: []andola_tto: [], including tickets that carry an SLA. The SLA fields came back as an object ornull.nullfor the OLA fields.ola_ttr.idanswers HTTP 500 on 12.0.1, so I couldn't observe what a populated OLA looks like there. This change makes no assumption about it.Tests
[]reads asNone.nullread as before.IdNameRef | Nonefails exactly that field's[]case.pytest -m "not integration" -W error::RuntimeWarning: 2256 passed, coverage 98.07%ruff check,ruff format --check, strictmypyunasync_build.py --checksphinx -W🤖 Generated with Claude Code