用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/navikt/sokos-ske-krav --skill slack-alerting命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
HOCON-basert konfigurasjon med PropertiesConfig singleton for Ktor batch-tjenester på NAIS (FSS)
Flyway-migrasjoner for PostgreSQL: navnekonvensjoner (V{n}__desc.sql), skjema for krav/feilmelding/filvalideringsfeil, DBListener-testing med TestContainers
Post-send livssyklus: StatusService poller /mottaksstatus; StoppKravService; RapportService + AvstemmingRouting-frontend for manuell reskontroføring
基于 SOC 职业分类
正在显示 SKILL.md
| name | slack-alerting |
| description | SlackService feilakkumulering og Tags-basert varsling for prosesseringsfeil i SKE-batch |
SlackService accumulates errors for a file/batch, then flushes them in a single call. Never call SlackClient.sendMessage() directly — accumulate first, send once.
slackService.addError(fileName, "Feil i validering av fil", errorMessages)
// ... more processing, more addError() calls ...
slackService.sendErrors() // flush once at the end, safe even if no errors accumulated
This prevents Slack rate-limiting and groups all errors for a file into one message.
class SlackService(private val slackClient: SlackClient = SlackClient()) {
fun addError(fileName: String, header: String, messages: Map<String, List<String>>)
fun addError(fileName: String, header: String, messages: Pair<String, String>)
fun addError(fileName: String, header: String, messages: List<Pair<String, String>>)
suspend fun sendErrors()
}
Internal state: MutableList<FileErrors>. sendErrors() iterates file errors, calls SlackClient.sendMessage() per header group, then clears the buffer.
The Tags enum maps specific SKE error types to on-call Slack user IDs and (optionally) a routine link:
private enum class Tags(
val personer: List<String>,
val rutineLink: String? = null,
val errorKey: String? = null,
) {
PERSON_EKSISTERER_IKKE(listOf(NAME_A, NAME_B)),
ORGANISASJON_ER_OPPHOERT(listOf(NAME_C, NAME_D), "https://confluence.adeo.no/…"),
FANT_IKKE_GYLDIG_KRAVIDENTIFIKATOR(listOf(NAME_E), errorKey = FeilResponse.CustomTitles.FANT_IKKE_GYLDIG_KRAVIDENTIFIKATOR),
// ...
;
companion object { val lookupMap: Map<String, Tags> = entries.associateBy { it.errorKey ?: it.name } }
}
The error key in the messages map passed to addError must match either it.errorKey (if set) or it.name exactly. SlackService.sendErrors() resolves it through lookupMap before calling SlackClient.sendMessage(...), so the right people are tagged.
valideringsFeil.error which comes directly from SKE in SCREAMING_SNAKE_CASE — use a matching enum name.FeilResponse.CustomTitles.FANT_IKKE_GYLDIG_KRAVIDENTIFIKATOR set as feilResponse.title): set errorKey to the shared constant and use that same value as the map key in messages.Adding a new tag:
Tags with personer (and optional rutineLink)name, no errorKey needederrorKey to itlookupMap and sendMessage() pick it upclass SlackClient(
private val slackEndpoint: String = PropertiesConfig.slackConfig.url,
private val client: HttpClient = slackHttpClient, // proxy-aware, needed on NAIS FSS
) {
suspend fun sendMessage(
header: String,
fileName: String,
messages: Map<String, List<String>>,
taggedPeople: List<String> = emptyList(),
rutineLink: String? = null,
)
}
Webhook URL comes from slack.url HOCON (env SOKOS_SKE_KRAV_SLACK_WEBHOOK_URL).
slack { url = ${SOKOS_SKE_KRAV_SLACK_WEBHOOK_URL} }
// Option 1: real SlackService with a no-op HTTP client
val slackService = SlackService(SlackClient(slackEndpoint = "", client = MockHttpClient.slackClient))
// Option 2: mock SlackService entirely
val slackServiceMock = mockk<SlackService> {
justRun { addError(any(), any(), any<List<Pair<String, String>>>()) }
coJustRun { sendErrors() }
}
MockHttpClient.slackClient is a pre-built HttpClient(MockEngine) that returns 200 OK to any request.
addError(...) + sendErrors() — never SlackClient.sendMessage() directly from service codesendErrors() exactly once at the end of each processing pass (e.g. per scheduler tick)Tags.name identical to the SKE error type stringerrorKey to the same shared constant used by feilResponse.titleTags entries (on-call people depend on them)Tags / config