Installation defaults: an allOf/anyOf/oneOf branch over a dictionary rejects a valid entry

Ouverte
#5,474 0 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 3 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
54/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
go
Domaine
backend

Piste de recherche

Start with prepareInstallationDefaultsFragment in pkg/registry/apps/application/installation_defaults.go and trace how it handles object branches under allOf, anyOf and oneOf. Reproduce the issue with the schema and entry in the report, then check that the entry is accepted and merged without the forbidden-property warning. The report notes that no current ApplicationDefinition has this shape, so testing requires a hand-written schema.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

area/api kind/bug triage/needs-triage
Describe the bug

Before merging an applicationDefaults entry the API checks it against the application schema and closes objects to unknown keys (additionalProperties: false) unless they declare a dictionary or preserve unknown fields. It does that also for an object inside an allOf, anyOf or oneOf branch, even when the property this branch constrains is declared as a dictionary next to it. A valid entry is refused, and every create of that kind goes on without defaults and returns a Warning.

Environment
  • Cozystack: main (since #5107)
To Reproduce

Application schema:

{"type":"object","properties":{"options":{"type":"object","additionalProperties":{"type":"string"}}},"allOf":[{"properties":{"options":{"type":"object","minProperties":1}}}]}

Entry {"options":{"a":"x"}}. The plain OpenAPI validator accepts it, applyInstallationDefaults refuses it.

Expected behaviour

Entry is accepted and merged.

Actual behaviour
options.a in body is a forbidden property
Additional context

prepareInstallationDefaultsFragment in pkg/registry/apps/application/installation_defaults.go. A branch fragment should take its openness from the declared property, not close itself. Same for an object without type inside a branch whose declared counterpart has no properties. None of the 32 ApplicationDefinitions in the tree has this shape and cozyvalues-gen does not produce it, so only a hand-written schema of an external catalog can hit it.

Langage dominant
Go
Étoiles
2.2k
Forks
209
Merge moyen
4 j 14 h
PR mergées (30 j)
140

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de cozystack/cozystack

Toutes les issues de cozystack/cozystack

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.