Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,68 @@ this file collects what users and scripts need to know.

## Unreleased

## 0.29.0 (2026-11-26)

### New

- `norcube cms validate -o json` (and `-o yaml`) gives each finding its
`cause`, which of the rule's causes it is, and `params`, the facts its
message is made of, typed (cms-schema 0.12.2). Kinds of value are codes
(`params.expected` and `params.actual`: `group_of_fields`,
`list_of_references`, `string`…), the vocabulary the module's
`report/catalog.json` lists. The table, `-o text` and the English
`message` and `hint` are unchanged. A skipped quality rule keeps its
English `reason` and gains `code` and `params`.
- LangSync key descriptions from the project: a namespace in
`.langsync.json` can name a `context_file`, a flat JSON object
`{"key": "what the key is"}` in the source language (a relative path is
resolved like `dir`). `langsync sync` sends the descriptions of the
source file's keys with the job, and the people and the model that
translate a key see it; an empty description clears one. Descriptions
of keys the source file doesn't have are not sent, with one warning
line giving the count. A missing file, invalid JSON, a value that isn't
text and a description longer than 1,000 characters stop the sync
before anything is sent, naming the file (and the key). A
`context_file` that sits directly in the namespace's `dir` with a
`.json` name is refused when the project file is read, because every
such file there is read as a language: keep it in a subdirectory such
as `context/en.json`. `langsync pull` doesn't read it. No new flag.
- `langsync namespaces create` and `update` take `--message-syntax plain|icu`:
what the namespace's strings are. With `icu` LangSync translates ICU
MessageFormat per plural form of each language and checks every
translation and every write before storing it. `namespaces list` shows
it in a SYNTAX column.
- The `langsync sync` summary lists every translation LangSync didn't
store, with the key, the language, the reason (`placeholders_changed`,
`icu_invalid`, `plural_forms`, `tags_changed`, `glossary_term_missing`,
`too_many_variants`, `untranslated`, `model_failed`) and its facts, and
"and N more" for the ones the server didn't list. A "Not reviewed"
block counts per language the translations nobody has marked reviewed.
A refusal of the descriptions (`SYNC_CONTEXTS_INVALID`) names the
context file and the key.

### Fixes

- `langsync init` keeps a namespace's `language_aliases` and
`context_file` when the namespace is picked again.

### Changes for scripts

- `langsync sync` / `pull` / `init -o json|yaml`: each namespace's summary
has `failures` (the job's entries: `phase`, `opIdx`, `mark`, `error`,
and for a translation not stored `code`, `languageCode`, `offset`,
`argument`, `missing`, `unexpected`; one entry with `dropped` stands for
the entries not listed) and `unreviewedPerLanguage` (`{languageCode:
count}`), both left out when the job has none. `-o text` columns are
unchanged.
- `langsync namespaces list -o json|yaml` has `messageSyntax` (`plain` or
`icu`); `-o text` has it as a new last column. `namespaces create` and
`update -o json` have `messageSyntax` when the command set it.
- A LangSync refusal whose body carries a data object (such as
`TERM_TRANSLATION_INVALID` from `translations set` or `terms add`, or
`TERM_IMPORT_TRANSLATIONS_INVALID` from `terms import`) has it in the
JSON error's `details.data`.

## 0.28.0 (2026-11-25)

### New
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,12 @@ norcube cms validate ./site --quality --git --strict-quality # in CI
- run: norcube cms validate --quality --git --strict-quality
```

`-o json` prints every finding with its rule id, and with `--quality` a
`quality` summary of what was checked, skipped and guessed.
`-o json` prints every finding with its rule id, its `cause` (which of
the rule's causes it is) and `params` (the facts its message is made of,
typed), and with `--quality` a `quality` summary of what was checked,
skipped and guessed. The English `message` and `hint` stay; a tool that
words findings itself keys on `rule`, `cause` and `params`, as the
module's `report/catalog.json` lists them.

## Documentation

Expand Down
8 changes: 6 additions & 2 deletions docs/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,8 @@ changelog, and the owner's decisions in the planning sessions of
| 2026-11-15 | `cms validate`: a `cms` group whose first command works on a site checkout, offline, with no sign-in. The checks live in the public `github.com/norcubeplatform/cms-schema` module, which the CMS service and the dashboard's fixtures share, so the CLI is a thin wrapper and cannot drift from the editor. `--fail-on` defaults to `error` (unlike `monitor status`, whose default is `none`) because a validator that exits 0 on errors would be useless in CI; findings keep their severity whatever `--fail-on` says. A failed run uses the new code `invalid`, not `unhealthy`: `unhealthy` describes a service's state, `invalid` what the command checked. The report is printed before the error so CI keeps it. The path argument completes directories only | Owner's brief: validate a whole site against every page, locally and in CI, with the rules the editor runs. Rejected: putting the checks in the CLI module (the private backend would then depend on the CLI's releases and dependency graph); a `--strict` flag (the tree already has `--fail-on` for this); naming the command `cms schema validate` (content and links are checked too) | owner |
| 2026-11-23 | `cms validate --quality` (cms-schema 0.10.0): the content quality checks run only when asked for, as in the module, because their findings are advice rather than breakage; they are warnings and notices, never errors, and notices never fail a run whatever `--fail-on` says. `--strict-quality` fails on quality warnings alone (unlike `--fail-on warning`, which also fails on correctness warnings). `--git` reads when each file last changed from `git log` with a deadline; it needs `--quality`, and a git failure ends the run with its own code (`usage_error` outside a checkout, `timeout`, `error`) instead of silently skipping the outdated-translation check the person asked for. Quality is a flag, not an `--only` value, so `--only` keeps meaning the correctness checks. A finding about one language of a page that holds every language shows the language after its path in the PATH column (`title.en [en]`); `-o json` has it as `locale` | Owner's brief: run the module's quality checks from the CLI, mirroring `cms-schema-validate`. Rejected: a LOCALE column (mostly empty, and placed after MESSAGE in `-o text`); skipping the outdated check when git fails (the person asked for it) | owner |
| 2026-11-25 | `cms validate --git` with cms-schema 0.11.0: an outdated translation is one whose source changed a translatable text since the translation last changed or was marked current, so `--git` hands the module a reader of the source's earlier versions (`gitlog.SourceBases`) instead of file dates. The history is read only when the checks have language versions to judge, under the same deadline; a read failure still ends the run with the same codes, and the deadline or an interrupt decides the code before what git printed (a killed `git rev-parse` reads as "not a repository"). A shallow clone is refused with `usage_error` (cms-schema 0.11.1, `gitlog.ErrShallowHistory`): its oldest commit lists every file as added, so every translation would look current, a silent pass in CI, where `actions/checkout` clones with depth 1 | A date says nothing about what changed: a changed link or a commit in another folder made a translation "outdated". Rejected: reading the history up front to fail early on a site without language versions (twice the git work for a check with nothing to judge) | owner |
| 2026-11-25 | `cms validate` with cms-schema 0.12.0: findings carry `cause` and typed `params` beside the English `message` and `hint`, added to `-o json`/`-o yaml` as the module emits them; the table and `-o text` print `message` as before. The module's skipped rule turned its `reason` from a sentence into a code (with `message`), so report version 1 keeps `quality.skipped[].reason` English and adds `code` and `params` (`qualityReport`), a CLI view of that one list over the module's summary | Owner's brief: findings are codes and parameters, words come from a catalog per client; the CLI stays English (I18N_BACKEND.md 4.3). Rejected: passing the module's `skipped` through (a changed meaning of a version 1 field needs the owner's agreement, 6.4); copying the whole summary into a CLI type (it would drift from the module) | owner |
| 2026-11-25 | LangSync key descriptions come from a `context_file` named per namespace in `.langsync.json`, read whenever it is configured (no flag), and only by commands that push (`pull` pushes nothing, so it doesn't read it). A file the language scan would read (`<name>.json` directly in `dir`, by the same rule as `ListLangsInDir`) is refused when the project file is loaded; descriptions of keys the source file lacks are left out with one warning line, because the server refuses them and a renamed key shouldn't stop a sync; the file being unreadable stops it before anything is sent. `--message-syntax` takes its values from the generated client's enum, checked against the spec by a test. The sync summary words each failure code itself and keeps the server's English for codes it doesn't know | The backend's key descriptions and message syntax (owner's i18n plan). Rejected: a `--contexts` flag (a project setting belongs in the project file); sending every description and letting the server refuse (one stale entry would fail the whole namespace) | owner |

---

Expand Down Expand Up @@ -1045,8 +1047,10 @@ observable contract and will be announced in the changelog.
7; a failed sync job is a plain error rather than `job_failed`; some
usage errors exit 1; several local "Cancelled." implementations; direct
`os.Stderr` writes; vocabulary mixes "mark" and "term" (`terms add` says
"Add a new mark"). `sync`, `pull`, `init` and the project file code have
no tests yet. Exit-code fixes here are "Changes for scripts".
"Add a new mark"). `sync`, `pull`, `init` and the project file code are
tested only for key descriptions (`context_file`), the summary and
`init` keeping an entry's hand-written fields. Exit-code fixes here are
"Changes for scripts".
- **JSON shapes (before 1.0).** Several write commands return ad-hoc maps
instead of the API resource; `backup policies list` returns attachments
instead of definitions with `--datasource`.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/gofrs/flock v0.13.0
github.com/google/uuid v1.6.0
github.com/jmespath-community/go-jmespath v1.1.1
github.com/norcubeplatform/cms-schema v0.11.1
github.com/norcubeplatform/cms-schema v0.12.2
github.com/oapi-codegen/runtime v1.4.0
github.com/pelletier/go-toml/v2 v2.3.1
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/norcubeplatform/cms-schema v0.11.1 h1:GWief9ru4UOTNlEjidKZ3LACcKWRDavJwz66l51gu1I=
github.com/norcubeplatform/cms-schema v0.11.1/go.mod h1:fY05NpvoygKgMBZjj3+R6KI1vko9CSJPJKS02n6WRh0=
github.com/norcubeplatform/cms-schema v0.12.2 h1:JjU+20g6X5J9faIYkmOfrdCJmWQ53KriH/mFor0uS4Q=
github.com/norcubeplatform/cms-schema v0.12.2/go.mod h1:fY05NpvoygKgMBZjj3+R6KI1vko9CSJPJKS02n6WRh0=
github.com/oapi-codegen/runtime v1.4.0 h1:KLOSFOp7UzkbS7Cs1ms6NBEKYr0WmH2wZG0KKbd2er4=
github.com/oapi-codegen/runtime v1.4.0/go.mod h1:5sw5fxCDmnOzKNYmkVNF8d34kyUeejJEY8HNT2WaPec=
github.com/oasdiff/yaml v0.1.1 h1:6nHx+pn9gBRM6YpBlFZFQGCCd1nuvqOBtTD3KKTgGxY=
Expand Down
6 changes: 6 additions & 0 deletions internal/api/apierror/apierror.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const maxRawBody = 500
type Typed struct {
Msg string
Type string
// Data is the body's machine-readable data object (a refusal's reason
// and facts), when it has one; it goes to the error's details.
Data any
}

// Format builds the standard "service METHOD URL: detail" error as a
Expand All @@ -51,6 +54,9 @@ func Format(service string, resp *http.Response, body []byte, typed ...*Typed) e
e.Message = fmt.Sprintf("status %d", e.HTTPStatus)
}
e.Code = clierr.CodeForStatus(e.HTTPStatus, e.Type)
if t.Data != nil {
e.Details = map[string]any{"data": t.Data}
}
return e
}
}
Expand Down
22 changes: 22 additions & 0 deletions internal/api/apierror/apierror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,25 @@ func TestFormatProblemScopeAndForbidden(t *testing.T) {
t.Errorf("text %q", err.Error())
}
}

func TestFormatTypedBodyKeepsItsData(t *testing.T) {
data := map[string]any{"reason": "too_long", "key": "checkout.total", "maxChars": 1000}
err := Format("langsync", respFor("POST", "https://api.test/s", 400), nil,
&Typed{Msg: "contexts invalid", Type: "SYNC_CONTEXTS_INVALID", Data: data})
var ce *clierr.Error
if !errors.As(err, &ce) {
t.Fatalf("not a clierr.Error: %T", err)
}
d, ok := ce.Details.(map[string]any)
if !ok || d["data"] == nil {
t.Fatalf("details %v", ce.Details)
}
if ce.Code != clierr.CodeValidation {
t.Fatalf("code %q", ce.Code)
}
// Without data there are no details.
_ = errors.As(Format("langsync", respFor("GET", "https://api.test/s", 400), nil, &Typed{Msg: "bad", Type: "X"}), &ce)
if ce.Details != nil {
t.Fatalf("details without data: %v", ce.Details)
}
}
Loading
Loading