Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

ValidationError for valid smithing_transform recipe

Aperta
#107 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
53/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start with the SmithingTransformRecipe validation reached through SmithingPage and inspect how recipe ingredients and results are modeled. Reproduce the failure using the linked smithing recipe examples, including object and array forms for base, addition, and template. Done when valid smithing_transform recipes validate and the reported web book build succeeds.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Using hexdoc 2.0.0rc1 (with Hex Casting 1.21.1 dev-53)

hexdoc fails to build the web book because of a ValidationError.

Example run:
https://github.com/hauveli/fishcasting/actions/runs/38210665289/job/114683851584

Files which (I think) are failing the validation:
https://github.com/hauveli/fishcasting/blob/main/src/common/main/resources/data/fishcasting/recipe/shepherds_rod_smithing.json
https://github.com/hauveli/fishcasting/blob/main/src/common/main/resources/data/fishcasting/recipe/blessed_bobber_smithing.json
https://github.com/hauveli/fishcasting/blob/main/src/common/main/resources/data/fishcasting/recipe/crystal_casting_rod_smithing.json (Edit: I think this one may also be relevant, as it is also referenced.)

(Edit: These are the patchouli pages affected)
https://github.com/hauveli/fishcasting/blob/main/src/common/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/items/casting_rod.json
https://github.com/hauveli/fishcasting/blob/main/src/common/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/fanciful_fishing.json

Possibly of note here, is that base, addition and template can be an Object or an Array of Objects, and still work in game.
Based on Misode, for 26.3 this becomes a String or an Array (of Strings).

Excerpts for the field "base" to show more clearly what I am referring to:
(from shepherds_rod_smithing.json)

  "base": {
    "item": "tide:crystal_fishing_rod"
  },

(from blessed_bobber_smithing.json)

  "base": [
    {
      "item": "tide:amethyst_bobber"
    }
  ],

The error from the example run:

  │ /home/runner/work/fishcasting/fishcasting/.venv/lib/python3.12/site-packages │
  │ /hexdoc/cli/ci.py:51 in build                                                │
  │                                                                              │
  │    48 │   │   pages_url = get_pages_url(env.repo)                            │
  │    49 │   os.environ["GITHUB_PAGES_URL"] = pages_url                         │
  │    50 │                                                                      │
  │ ❱  51 │   site_path = hexdoc_app.build(                                      │
  │    52 │   │   Path("_site/src/docs"),                                        │
  │    53 │   │   clean=True,                                                    │
  │    54 │   │   branch=env.branch,                                             │
  │                                                                              │
  │ /home/runner/work/fishcasting/fishcasting/.venv/lib/python3.12/site-packages │
  │ /hexdoc/cli/app.py:264 in build                                              │
  │                                                                              │
  │   [261](https://github.com/hauveli/fishcasting/actions/runs/38210665289/job/114683851584#step:6:275) │   │   │   │   │   i18n=i18n,                                         │
  │   [262](https://github.com/hauveli/fishcasting/actions/runs/38210665289/job/114683851584#step:6:276) │   │   │   │   │   all_metadata=all_metadata,                         │
  │   [263](https://github.com/hauveli/fishcasting/actions/runs/38210665289/job/114683851584#step:6:277) │   │   │   │   ) as context:                                          │
  │ ❱ [264](https://github.com/hauveli/fishcasting/actions/runs/38210665289/job/114683851584#step:6:278) │   │   │   │   │   book = book_plugin.validate_book(book_data, contex │
  │   [265](https://github.com/hauveli/fishcasting/actions/runs/38210665289/job/114683851584#step:6:279) │   │   │   │   books.append(                                          │
  │   [266](https://github.com/hauveli/fishcasting/actions/runs/38210665289/job/114683851584#step:6:280) │   │   │   │   │   LoadedBookInfo(                                    │
  │   [267](https://github.com/hauveli/fishcasting/actions/runs/38210665289/job/114683851584#step:6:281) │   │   │   │   │   │   language=language,                             │
  │                                                                              │
  │ /home/runner/work/fishcasting/fishcasting/.venv/lib/python3.12/site-packages │
  │ /hexdoc/_hooks.py:169 in validate_book                                       │
  │                                                                              │
  │   166 │   │                                                                  │
  │   167 │   │   book = Book.model_validate(book_data, context=cast_context(con │
  │   168 │   │   book._load_categories(context, book_ctx)                       │
  │ ❱ 169 │   │   book._load_entries(context, book_ctx, loader)                  │
  │   170 │   │                                                                  │
  │   171 │   │   return book                                                    │
  │   172                                                                        │
  │                                                                              │
  │ /home/runner/work/fishcasting/fishcasting/.venv/lib/python3.12/site-packages │
  │ /hexdoc/patchouli/book.py:130 in _load_entries                               │
  │                                                                              │
  │   127 │   │   │   folder="entries",                                          │
  │   128 │   │   │   use_resource_pack=self.use_resource_pack,                  │
  │   129 │   │   ):                                                             │
  │ ❱ 130 │   │   │   entry = Entry.load(resource_dir, id, data, cast_context(co │
  │   131 │   │   │   if not entry.is_flag_enabled:                              │
  │   132 │   │   │   │   logger.info(f"Skipping entry {id} due to disabled flag │
  │   133 │   │   │   │   continue                                               │
  │                                                                              │
  │ /home/runner/work/fishcasting/fishcasting/.venv/lib/python3.12/site-packages │
  │ /hexdoc/model/id.py:35 in load                                               │
  │                                                                              │
  │   32 │   │   context: dict[str, Any],                                        │
  │   33 │   ) -> Self:                                                          │
  │   34 │   │   logger.log(TRACE, f"Load {cls} at {id}")                        │
  │ ❱ 35 │   │   return cls.model_validate(                                      │
  │   36 │   │   │   data | {"id": id, "resource_dir": resource_dir},            │
  │   37 │   │   │   context=context,                                            │
  │   38 │   │   )                                                               │
  │                                                                              │
  │ /home/runner/work/fishcasting/fishcasting/.venv/lib/python3.12/site-packages │
  │ /pydantic/main.py:732 in model_validate                                      │
  │                                                                              │
  │    729 │   │   │   │   code='validate-by-alias-and-name-false',              │
  │    730 │   │   │   )                                                         │
  │    731 │   │                                                                 │
  │ ❱  732 │   │   return cls.__pydantic_validator__.validate_python(            │
  │    733 │   │   │   obj,                                                      │
  │    734 │   │   │   strict=strict,                                            │
  │    735 │   │   │   extra=extra,                                              │
  ╰──────────────────────────────────────────────────────────────────────────────╯
  ValidationError: 2 validation errors for Entry
  pages.2.Page
    Failed to match union <class 'hexdoc.patchouli.page.abstract_pages.Page'>: No 
  match found
    Types: <class 'hexdoc.patchouli.page.pages.SmithingPage'>
    Value: {'type': 'patchouli:smithing', 'recipe': 
  'fishcasting:crystal_casting_rod_smithing', 'text': 
  'fishcasting.page.casting_rod.smithing', '__resolved': True}
    Tag: type=patchouli:smithing [type=TaggedUnionMatchErrorGroup, 
  input_value={'type': 'patchouli:smith...e.casting_rod.smithing'}, 
  input_type=dict]
  pages.2.Page.SmithingPage
    ValidationError: 2 validation errors for SmithingPage
  recipe.SmithingRecipe
    Failed to match union <class 
  'hexdoc.minecraft.recipe.recipes.SmithingRecipe'>: No match found
    Types: <class 'hexdoc.minecraft.recipe.recipes.SmithingTransformRecipe'>
    Value: {'type': 'minecraft:smithing_transform', 'addition': {'item': 
  'hexcasting:charged_amethyst', '__resolved': True}, 'base': [{'item': 
  'minecraft:fishing_rod'}, {'item': 'tide:stone_fishing_rod'}, {'item': 
  'tide:iron_fishing_rod'}, {'item': 'tide:golden_fishing_rod'}], 'result': 
  {'count': 1, 'id': 'tide:crystal_fishing_rod'}, 'template': {'tag': 'c:strings',
  '__resolved': True}, 'id': fishcasting:crystal_casting_rod_smithing, 
  'resource_dir': PathResourceDir(external=False, reexport=True, required=True, 
  path=PosixPath('/home/runner/work/fishcasting/fishcasting/doc/../src/common/main
  /resources'), archive=False), '__resolved': True}
    Tag: type=minecraft:smithing_transform [type=TaggedUnionMatchErrorGroup, 
  input_value={'type': 'minecraft:smith...urces'), archive=False)}, 
  input_type=dict]
  recipe.SmithingRecipe.SmithingTransformRecipe
    ValidationError: 5 validation errors for SmithingTransformRecipe
  base
    Input should be a valid dictionary or instance of ItemIngredient 
  [type=model_type, input_value=[{'item': 
  'minecraft:fish...de:golden_fishing_rod'}], input_type=list]
      For further information visit https://errors.pydantic.dev/2.13/v/model_type
  result.function-after[_set_name(), 
  function-wrap[_wrap_root_load_from_id()]].item
    Field required [type=missing, input_value={'count': 1, 'id': 
  'tide:crystal_fishing_rod'}, input_type=dict]
      For further information visit https://errors.pydantic.dev/2.13/v/missing
  result.function-after[_set_name(), 
  function-wrap[_wrap_root_load_from_id()]].count
    Extra inputs are not permitted [type=extra_forbidden, input_value=1, 
  input_type=int]
      For further information visit 
  https://errors.pydantic.dev/2.13/v/extra_forbidden
  result.function-after[_set_name(), function-wrap[_wrap_root_load_from_id()]].url
    Field required [type=missing, input_value={'count': 1, 'id': 
  'tide:crystal_fishing_rod'}, input_type=dict]
      For further information visit https://errors.pydantic.dev/2.13/v/missing
  result.function-after[_set_name(), 
  function-wrap[_wrap_root_load_from_id()]].count
    Extra inputs are not permitted [type=extra_forbidden, input_value=1, 
  input_type=int]
      For further information visit 
  https://errors.pydantic.dev/2.13/v/extra_forbidden [type=TaggedUnionMatchError, 
  input_value={'type': 'minecraft:smith...urces'), archive=False)}, 
  input_type=dict] [type=TaggedUnionMatchError, input_value={'type': 
  'patchouli:smith...e.casting_rod.smithing'}, input_type=dict]
  Error: Process completed with exit code 1.
Lingua principale
Python
Stelle
7
Fork
10
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hexdoc-dev/hexdoc

Tutte le issue di hexdoc-dev/hexdoc

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.